Tag: angular度cli

Angular 2 ng构build

所以我需要创build一个可以运行而不需要运行服务器的版本。 运行生成。 有一个dist文件夹。 当我运行index.html我得到一个错误 GET file:///D:/inline.bundle.js net::ERR_FILE_NOT_FOUND 他正在我的D://驱动器的根目录中search该js文件,而不是在项目文件夹中 好吧,我从我的index.html删除了一个<base href="/"> ,并得到这个错误: Unhandled Promise rejection: No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document. ; Zone: <root> ; Task: Promise.then ; Value: ZoneAwareError {__zone_symbol__error: Error: No base href set. Please provide a value for the […]

致命错误:CALL_AND_RETRY_LAST分配失败 – ngtesting – 观察

我在以下环境中开发了一个angular-cli应用程序: OS: Windows 10 Nodejs: 6.9.2 npm: 3.3.10 angular-cli: 1.0.0-beta.25.5 当我在做ng test –watch时候更改代码 – 每当我得到以下错误: <— Last few GCs —> 541882 ms: Mark-sweep 1369.1 (1393.2) -> 1369.0 (1394.2) MB, 233.9 / 0.1 ms [allocation failure] [GC in old space requested]. 542130 ms: Mark-sweep 1369.0 (1394.2) -> 1369.0 (1395.2) MB, 248.3 / 0.0 ms [allocation failure] […]

当服务器将事件发送到特定客户端时,不要使用Angular2来运行socket.io-client(不同的angular2服务)

我创build了两个服务send-message.service.ts import { Injectable } from "@angular/core"; import * as io from 'socket.io-client'; @Injectable() export class SendMessageService { private url = 'http://localhost:4000'; private socket = io(this.url); saveUser(user) { this.socket.emit('joining-to-chat', user); } sendMessage(data) { this.socket.emit('send-message', data); } } 和receive-message.service.ts import { Injectable } from "@angular/core"; import { Subject } from 'rxjs/Subject'; import { Observable } from […]

如何在Docker容器中安装全局的angular-cli?

我使用下面的dockerfile创build了一个由angular-cli创build的angular2应用程序的图像。 FROM node:latest MAINTAINER BHUSHAN GADEKAR ENV NODE_ENV=production ENV PORT=4200 COPY . /var/www WORKDIR /var/www RUN npm install EXPOSE $PORT ENTRYPOINT ["npm","start"] 成功创build图像后,我尝试使用下面的命令运行此图像 docker run –rm -p 8080:4200 -w "/var/www" bhushan001/angular2-cli npm start 现在我可以看到我的容器开始了,但是运行错误: ng服务“npm”“开始”sh:1:ng:找不到 所以我知道angular-cli不存在于我的容器中,但是我使用npm install在dockerfile中本地npm install了它。 任何投入? 提前致谢。 我怎样才能解决这个问题?

Angular 2 CLIvariables不会被更新

首先,我对Angular 2完全陌生,昨天我尝试使用Angular CLI进行我的第一个项目,但是失败了。 Angular CLI似乎不适合我 – 我的意思是,variables没有在我的意见中得到更新。 我在这里做了标准的程序: 新的项目名称 cd项目名称 npm开始 localhost:4200服务器启动,然后尝试向/src/app/app.component.html模板中添加一个新元素 – 段落: <p>This text gets displayed</p> CLI告诉我,一切正常,浏览器自动刷新,然后我看到默认的“应用程序的作品!” 标题和我的新段落里面的文字。 但是,我决定改变app.component.ts文件中的titlevariables,所以我的新类声明如下所示: export class AppComponent { title = 'New App Title!'; } CLI再次告诉我,一切正常,但没有在浏览器中看到变化。 我手动刷新页面,但没有更改 – 标题仍然表示“应用程序工作!”。 所以我尝试添加一个新的variables到文件中: otherText = "some other text"; 然后在我的模板中添加另一段: <p>New text: {{otherText}}</p> 该段落显示在网页上,但{{otherText}}variables内容丢失。 该页面看起来像这样: <h1>app works!</h1> <p>this text gets displayed</p> <p>New text: […]

出现错误'在angular2应用程序中运行服务时,无法读取未定义的属性'长度'

而使用angular-cli命令运行angular2应用程序ng-serve我收到以下问题 dashboard@0.0.0启动C:\ Users \ padmavathi \ Downloads \ phototype-development \ web \ dashboard ng serve Cannot read property 'length' of undefined TypeError: Cannot read property 'length' of undefined at createSourceFile (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\typescript\lib\typescript.js:8980:109) at parseSourceFileWorker (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\typescript\lib\typescript.js:8940:26) at Object.parseSourceFile (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\typescript\lib\typescript.js:8899:26) at Object.createSourceFile (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\typescript\lib\typescript.js:8727:29) at new TypeScriptFileRefactor (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\@ngtools\webpack\src\refactor.js:25:35) at Object.resolveEntryModuleFromMain (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\@ngtools\webpack\src\entry_resolver.js:108:18) at AotPlugin._setupOptions (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\@ngtools\webpack\src\plugin.js:129:58) at new AotPlugin (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\@ngtools\webpack\src\plugin.js:37:14) at […]

为什么Angular 2不加载默认的应用程序根组件?

我试图通过angularCLI生成Angular应用程序,但它似乎像默认的app-root组件不加载。 需要说的是,我正在使用angular应用程序和快递服务器之间的连接代理,并且我正在同时运行两个脚本: node bin/www express / node.js启动和ng serve –proxy-config proxy.config.json用于启动Angular并创build代理连接的ng serve –proxy-config proxy.config.json ,它看起来像这样(package.json的一部分): "scripts": { "start": "concurrently –kill-others \"node bin/www\" \"ng serve –proxy-config proxy.config.json\"" } 索引页面加载正常,但似乎app-root组件(默认组件,它是从angularCLI ng new创build的)不加载: 这里是我的node.js / express use s和一个路由: var express = require('express'); var router = express.Router(); var app = express(); var path = require('path'); app.use(express.static('./src/client/')); app.use(express.static('./')); app.use(express.static('./tmp')); app.use('/*', express.static(path.resolve('src/client/index.html'))); […]

添加服务器端代码到angular-cli项目与节点types冲突

当添加一个基本的express.jsconfiguration(使用TypeScript)到一个Angular2项目,该项目已经用angular-cli ng new [project-name]初始化了,我需要添加下面的代码来使用gulp编译express服务器: types安装 – 环境 – 保存节点 这typings/main.d.ts添加到typings/browser.d.ts和typings/main.d.ts /// <reference path="browser/ambient/node/index.d.ts" /> and /// <reference path="main/ambient/node/index.d.ts" /> 在express server.ts文件中,我可以添加一个引用而不是browser来保持TypeScript的快乐 /// <reference path="../typings/main.d.ts" /> 但是,当我离开browser.d.ts文件中的节点types引用时, ng build命令将失败: Build failed. The Broccoli Plugin: [BroccoliTypeScriptCompiler] failed with: Error: Typescript found the following errors: C:/Users/user123/Downloads/my-catalog-master/my-catalog-master/tmp/broccoli_type_script_compiler-input_base_path-7VFCE2dg.tmp/0/src/typings.d.ts (3, 13): Subsequent variable declarations must have the same type. Variable 'module' […]

如何添加自定义css和jsangular4

在angular2中,我可以将它们添加到index.html中,如下所示: <link rel="stylesheet" href="css/mycss.css"> 但是在angular 4中,它必须被添加到样式和脚本数组部分中的angular-cli.json文件中。 在我的情况下,他们似乎并没有被加载。 没有错误,但当我在浏览器中查看应用程序,我知道样式没有加载。 当我将样式和js添加到index.html文件时,它也不会被加载,我在控制台中得到一个404。 我该如何解决? 以下是我的Angular cli版本:@ angular / cli:1.0.2 Node:6.9.2

在开发环境中使用Angular CLI连接express.js

我find了一个很好的教程,解释了如何使用Angular CLI设置express.js,但在本教程中,angular度应用程序被编译到生产dist文件夹中: https : //scotch.io/tutorials/mean-app-with-angular- 2 -和-的棱angular-CLI 如何将express.js与Angular CLI集成,但我希望express.js能够与Angular应用程序的开发版本一起工作,并且如果我更改了express或angular应用程序,我希望nodemon重新启动。 已经花了八个小时试图让这个工作。 谢谢! 我不想在每次修改Angular应用程序时运行“ng build”(这需要太长的时间) – 我想要在我的angular度应用程序中保存更改时立即重新加载(就像我正在运行'ng serve ')或表示应用程序。 我find了一个教程,在这里你使用Express来连接Angular 2 QuickStart,它可以工作,但是我正在使用Angular CLI。 我知道Angular CLI使用WebPack,而QuickStart使用System.js