问题描述
我是 angular-cli
的新用户,并使用 ng new angular2
命令创建了一个角度为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
-
Sharing the config that I get on running ng --version
-
angular-cli: 1.0.0-beta.18
node: 6.9.5
os: win32 x64
感谢您的帮助。
推荐答案
我有同样的问题,你仍然使用角度cli的beta版本 - 他们现在有一个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).
注意:不是必需但如果您没有运行节点6.9 +
Note: Not essential but it will also give you warnings if you aren't running Node 6.9 +
这篇关于用简单的新角度cli项目投掷错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!