ng 使用简单的 ng new angular cli 项目抛出错误 [英] ng serve throwing errors with simple ng new angular cli project

查看:42
本文介绍了ng 使用简单的 ng new angular cli 项目抛出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 angular-cli 的新手,并使用 ng new angular2 命令创建了一个 angular 2 项目.现在,当我尝试使用 ng serve 运行它时,它会因一些错误而崩溃.

I am new to a angular-cli and have created an angular 2 project with ng new angular2 command. Now when I try to run it with ng serve, it just crashes with some errors.

日志:

ERROR in [default] C:\Users\user\desktop\angularcli\node_modules\@types\jasmine\index.d.ts:39:37
A parameter initializer is only allowed in a function or constructor implementation.

ERROR in [default] C:\Users\user\desktop\angularcli\node_modules\@types\jasmine\index.d.ts:39:45
Cannot find name 'keyof'.

ERROR in [default] C:\Users\user\desktop\angularcli\node_modules\@types\jasmine\index.d.ts:39:51
'=' expected.
Child html-webpack-plugin for "index.html":
         Asset     Size  Chunks       Chunk Names
    index.html  2.81 kB       0
webpack: Failed to compile.

我不知道为什么会收到此跟踪信息,因为我没有对文件进行任何更改.有谁知道为什么会发生此错误,或者之前有人可能遇到过.

I don't know why I get this trace as I haven't made any changes in the files. Does anyone know why this error occurs or someone might have encountered it before.

分享我在运行 ng --version-

angular-cli: 1.0.0-beta.18
node: 6.9.5
os: win32 x64

感谢您的帮助.

推荐答案

我遇到了同样的问题,您仍在使用 angular cli 的测试版 - 他们现在有一个 RC 版本.升级将解决您的问题.另外值得注意的是,该项目已移入 NPM,现在是 @angular/cli 而不是 angular-cli.

I had this same problem, you are still using the beta version of angular cli - they have now have an RC version. Upgrading will fix your issue. Also worth noting that the project has moved in NPM it is now @angular/cli instead of angular-cli.

此页面将向您展示如何升级 -它提供了有关如何全局升级以及如何升级单个项目的说明(您需要同时执行这两项操作).

This page will show you how to upgrade - it gives instructions on how to upgrade globally and also how to upgrade individual projects (you will need to do both).

注意:不是必需的,但如果您没有运行 Node 6.9 +,它也会给您警告

Note: Not essential but it will also give you warnings if you aren't running Node 6.9 +

这篇关于ng 使用简单的 ng new angular cli 项目抛出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆