ng serve throwing errors with simple ng new angular cli project

时光怂恿深爱的人放手 提交于 2019-12-11 04:48:28

问题


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.

Log:

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.

Sharing the config that I get on running ng --version-

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

Thanks for helping.


回答1:


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).

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



来源:https://stackoverflow.com/questions/42595263/ng-serve-throwing-errors-with-simple-ng-new-angular-cli-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!