问题标签 [angular2-cli]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
2705 浏览

javascript - Upgrade angular 2 dependencies inside angular2-cli project

After playing around with angular2 and following angular2 guide in thier website I tryied to move to angular2-cli but angular2-cli project doesnt have the most updated dependencies so the compiler give me some errors about some commands in the code.

I want to upgrade all of the dependencies like core,router and more. the most updated router need the most updated core but when I try to do: npm install core -g, i get a lots of errors.

What is the best and fast way to upgrade all the exsisting dependencies?

Here are the package.json of angular-cli and angular website:

angular2-cli - orginial package.json:

most updated angular2 dependencies from angular2 website:

0 投票
2 回答
209 浏览

angular - 使用 Angular CLI 的 Angular 2 材质

  • 到目前为止,我使用 angular 2 quickstart 创建了一个新项目。

  • 我决定开始使用 angular 2 cli 并创建了一个新的 angular 2 cli 项目。

  • 移动了我所有的文件并再次安装了所有软件包。

现在,当我尝试在我的 CLI 项目中使用 angular 2 材料时,我按照此处的指南进行操作,但这就是我得到的:

在此处输入图像描述

可能出了什么问题?

0 投票
3 回答
15227 浏览

typescript - 如何将 SockJS 添加到 Angular 2 项目中?

我使用 angular-cli 生成一个新项目。现在我想将 socketJs 添加到项目中,但在浏览器控制台中不断出现错误:

这是我的步骤和配置:

角-cli-build.js

系统配置.ts

我的自定义服务类:

请告诉我如何解决它,非常感谢!

但是,我可以通过在 system-config.ts 中一一添加缺少的库来消除一些错误。但我怀疑这是正确的方法。

0 投票
0 回答
57 浏览

angular - Angular 2 CLI 如何为构建加载插件(例如移动工具包)

在以前的版本中,CLI 有一个巨大的 broccoli 配置文件。使用它,可以定义 - 例如 - CLI 必须如何创建构建。由于这个文件现在已经消失了,我想知道 CLI 如何知道调用 ng build 时要做什么。

例如,它使用 @angular/service-worker 和 @angular/app-shell 包(如果有的话)。

祝愿,曼弗雷德

0 投票
1 回答
560 浏览

javascript - #each scripts.polyfills 来自谁?

我已经使用 angular 2 CLI 生成了一个 angular 2 应用程序。

在 index.html 文件中是这样的:

当使用 CLI 命令“ng build”构建应用程序时,index.html 的输出为:

现在我问你#each 来自哪里意味着什么语言/库?

我的 CLI 创建的 angular 2 应用程序中定义的 scripts.polyfills 对象在哪里。

我在任何地方都找不到任何名称为“脚本”的文件夹/变量。

0 投票
1 回答
1437 浏览

angular - 使用 ng build 时生成错误

从 CLI 创建新的 angular2 应用程序后,我收到此错误:“您必须在 angular-cli 项目中才能使用构建命令”。我在项目目录中,我不明白错误的含义。

0 投票
1 回答
1113 浏览

angular - 在 angular2cli 应用程序中执行 php 文件

使用 angular2cli 创建 angular2 应用程序 php 文件未正确编译,想知道 angular cli 附带的服务器是否理解 php。如果没有,对 angular2cli 了解 php 有什么建议吗

0 投票
1 回答
395 浏览

javascript - 在进行 Angular 2 CLI 项目时如何添加第三方包

我目前正在开发一个使用 Angular 2 CLI 结构的 Angular 2 项目。我可以添加时刻,ng-material2,ng2-bootstrap,这些都很好,但是如果我尝试添加像JsonWebToken这样的包,那么我将无法正确设置我的文件。

注意:jsonwebtoken 不是为 Angular 2 或 Angular 2 CLI 构建的。它只是我尝试使用的一个 npm 包。

我已尝试按照angular2-cli 3rd 方库中描述的设置进行操作,但它仍然无法正常工作。

这是我的设置方式:

角-cli-build.js:

系统配置.js:

应用组件:

0 投票
1 回答
2308 浏览

angular - 如何让我的应用程序(通过 ng serve 运行)连接到 Node 后端,同时保留自动重新加载功能?

我刚刚将我的应用程序迁移到 Angular CLI。我已经启动并运行了我的 REST API 节点服务器。我希望能够运行我的前端ng serve,每次更改文件时都有自动重新加载功能,但也让它连接到我的节点后端。

Livereload 服务器正在端口 49152 上运行 在端口 4200 上提供服务 节点在端口 8080 上侦听

我所有的节点路由都以api.

这可能吗?

0 投票
0 回答
285 浏览

express - 使用 Express 服务器时缺少与“ember-cli-live-reload.js”相关的错误(未加载)

在使用 Express 服务器提供由 Angular-CLI 示例应用程序生成的内容时,我收到以下错误:

http://localhost:4200/ember-cli-live-reload.js加载资源失败:服务器响应状态为 500(内部服务器错误)

操作系统:Windows 7

版本:

angular-cli:1.0.0-beta.10 节点:5.11.1 操作系统:win32 x64 express:4.13.4 复制步骤:

使用 ng serve 或 node server.js 启动应用后访问 URL 后,Chrome 开发者工具栏出现此错误:` http://localhost:4200/ember-cli-live-reload.js Failed to load resource: the服务器响应状态为 500(内部服务器错误)

控制台中的这个异常:TypeError: res.status is not a function at C:\xxxx\server.js:43:7 at Layer.handle [as handle_request] (C:\xxxx\node_modules\express\lib\router \layer.js:95:5) 在 trim_prefix (C:\xxxx\node_modules\express\lib\router\index.js:312 :13) 在 C:\xxxx\node_modules\express\lib\router\index.js :280:7 在 Function.process_params (C:\xxxx\node_modules\express\lib\router\ index.js:330:12) 在下一个 (C:\xxxx\node_modules\express\lib\router\index.js: 271:10) 在 SendStream.error (C:\xxxx\node_modules\serve-static\index.js:121:

任何解决方法或解决此问题的方法?有人试过在 Angular-CLI 上使用 Express 吗?