简体   繁体   English

Angular CLI和angular 4不起作用

[英]Angular CLI and angular 4 not work ng serve

When I do ng serve I get this result 当我上菜时我得到这个结果

angular\router\@angular\router.es5.jsError: No module factory available   for dependency type: ContextElementDependency
at Compilation.addModuleDependencies
node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:264
                           if(_this.profile) {
                                   ^
TypeError: Cannot read property 'profile' of null
at factoryCallback

angular-cli 角度cli

"dependencies": { "@angular/animations": "^4.0.1", "@angular/common": "^4.0.0", ... “ dependencies”:{“ @ angular / animations”:“ ^ 4.0.1”,“ @ angular / common”:“ ^ 4.0.0”,...

I had the same problem and I solved it by doing the following steps: 1- remove webpack from package.json 2- delete node_modules folder 3- install webpack globally using the following commands: npm install webpack -g npm install webpack-dev-server -g 4- run npm install 我遇到了同样的问题,并通过执行以下步骤解决了这个问题:1-从package.json中删除webpack 2-删除node_modules文件夹3-使用以下命令全局安装webpack:npm install webpack -g npm install webpack-dev-server -g 4-运行npm安装

Note: If (npm start) generates error try to remove (package-lock.json), delete node_modules, and run "npm install" again 注意:如果(npm start)生成错误,请尝试删除(package-lock.json),删除node_modules,然后再次运行“ npm install”

As angular 4 is out, use ng new to generate new angular project as it is mentioned in the change log of angular cli and then try it 当角度4消失时,使用ng new生成新的角度项目,如角度cli的更改日志中所述,然后尝试

https://github.com/angular/angular-cli/blob/master/CHANGELOG.md https://github.com/angular/angular-cli/blob/master/CHANGELOG.md

or you must update your angular cli https://github.com/angular/angular-cli#updating-angular-cli 否则您必须更新您的angular cli https://github.com/angular/angular-cli#updating-angular-cli

Based on your comment, 根据您的评论,

In the another machine, install Angular-CLI by using 在另一台计算机上,通过使用安装Angular-CLI

npm install angular-cli -g

Then try running your app through ng serve 然后尝试通过ng serve运行您的应用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM