简体   繁体   中英

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

"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

Note: If (npm start) generates error try to remove (package-lock.json), delete node_modules, and run "npm install" again

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

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

Based on your comment,

In the another machine, install Angular-CLI by using

npm install angular-cli -g

Then try running your app through ng serve

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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