angular-cli: ng init cannot find @angular/core after update
Please provide us with the following information:
OS?
Windows 10
Versions.
1.0.0-beta.16
Repro steps.
Update the angular-cli from 1.0.0-beta.15 to 1.0.0-beta.16 following the update procedure in README.md
The log given by the failure.
c:\Users\f.dehopre\devs\RnD\angular2\demo-app\angular2>ng init
Cannot find module '@angular/core'
Error: Cannot find module '@angular/core'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\f.dehopre\devs\RnD\angular2\demo-app\angular2\node_modules\@ngtools\webpack\src\plugin.js:4:14)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\f.dehopre\devs\RnD\angular2\demo-app\angular2\node_modules\@ngtools\webpack\src\index.js:6:10)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\f.dehopre\devs\RnD\angular2\demo-app\angular2\node_modules\angular-cli\models\webpack-build-typescript.js:5:17)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\f.dehopre\devs\RnD\angular2\demo-app\angular2\node_modules\angular-cli\models\webpack-config.js:2:34)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\f.dehopre\devs\RnD\angular2\demo-app\angular2\node_modules\angular-cli\tasks\build-webpack.js:6:24)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\f.dehopre\devs\RnD\angular2\demo-app\angular2\node_modules\angular-cli\commands\build.js:3:23)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Class.module.exports.includedCommands (C:\Users\f.dehopre\devs\RnD\angular2\demo-app\angular2\node_modules\angular-cli\addon\index.js:20:16)
at C:\Users\f.dehopre\devs\RnD\angular2\demo-app\angular2\node_modules\angular-cli\lib\models\project.js:392:61
at Array.forEach (native)
at Project.addonCommands (C:\Users\f.dehopre\devs\RnD\angular2\demo-app\angular2\node_modules\angular-cli\lib\models\project.js:391:15)
at Project.eachAddonCommand (C:\Users\f.dehopre\devs\RnD\angular2\demo-app\angular2\node_modules\angular-cli\lib\models\project.js:426:30)
at module.exports (C:\Users\f.dehopre\devs\RnD\angular2\demo-app\angular2\node_modules\angular-cli\lib\cli\lookup-command.js:33:13)
at CLI.<anonymous> (C:\Users\f.dehopre\devs\RnD\angular2\demo-app\angular2\node_modules\angular-cli\lib\cli\cli.js:34:26)
at tryCatch (C:\Users\f.dehopre\devs\RnD\angular2\demo-app\angular2\node_modules\rsvp\dist\rsvp.js:538:12)
at invokeCallback (C:\Users\f.dehopre\devs\RnD\angular2\demo-app\angular2\node_modules\rsvp\dist\rsvp.js:553:13)
at publish (C:\Users\f.dehopre\devs\RnD\angular2\demo-app\angular2\node_modules\rsvp\dist\rsvp.js:521:7)
at flush (C:\Users\f.dehopre\devs\RnD\angular2\demo-app\angular2\node_modules\rsvp\dist\rsvp.js:2370:5)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 7
- Comments: 31 (7 by maintainers)
Commits related to this issue
- chore(docs): update update instructions. See https://github.com/angular/angular-cli/issues/2410#issuecomment-255880974 for more information. — committed to filipesilva/angular-cli by filipesilva 8 years ago
- chore(docs): update update instructions See https://github.com/angular/angular-cli/issues/2410#issuecomment-255880974 for more information. — committed to filipesilva/angular-cli by filipesilva 8 years ago
- chore(docs): update update instructions See https://github.com/angular/angular-cli/issues/2410#issuecomment-255880974 for more information. Close #2870 — committed to angular/angular-cli by filipesilva 8 years ago
- chore(docs): update update instructions See https://github.com/angular/angular-cli/issues/2410#issuecomment-255880974 for more information. Close #2870 — committed to MRHarrison/angular-cli by filipesilva 8 years ago
@filipesilva I thought this was now supported… but after updating the angular-cli to beta 18, I still have the same issue. Here is my package.json
And the stack trace:
@filipesilva yes, I did follow the whole update procedure. And I succeed to reproduce this issue on another project.
@JanStureNielsen This is the issue. I also upgraded angular to 2.0.1 and got this issue with ng init when updatet to beta16 and now also to beta17.
Same issue on OS X 10.11.6
@FabienDehopre I did some more investigation and think I know what’s happening now…
Basically, when we do
npm install --save-dev angular-cli@latest
AND there is a difference in@angular/core
versions between your project andangular-cli
, we don’t getnode_modules/@angular/core
but rathernode_modules/angular-cli/node_modules/@angular/core
(notice the nesting).On the other hand, the new-ish
@ngtools/webpack
has a peer dependency on@angular/core
- which it can’t find in the top-level ofnode_modules/
. Song init
fails.We definitely want
@ngtools/webpack
to use@angular/core
as a peer dependency, to ensure compatibility with the current project.So the solution here is to update the upgrade instructions and add the extra
npm install
step, that wasn’t needed before but now is due to@ngtools/webpack
.Thank you for the reports and pushing this issue, it was very hard to reproduce due to the
@angular/core
versions, which didn’t always change but were commonly different in projects that were upgraded several times.Exactly same issue in cli beta17
@JanStureNielsen This is exactly that issue. I forgot to mention that I was using angular 2.0.1 instead of the 2.0.0 that angular-cli install by default. My bad :-s
👍 I am experiencing the same issue on Ubuntu Linux 16.04