angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng init cannot find @angular/core after update

Open FabienDehopre opened this issue 10 years ago • 31 comments

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)

FabienDehopre avatar Sep 29 '16 07:09 FabienDehopre

:+1: I am experiencing the same issue on Ubuntu Linux 16.04

jfmaeck avatar Sep 29 '16 08:09 jfmaeck

Same issue on OS X 10.11.6

boardman avatar Sep 29 '16 11:09 boardman

Had the same, resolved with: npm install

Bulan avatar Sep 29 '16 14:09 Bulan

yep same issue

elvirdolic avatar Sep 29 '16 15:09 elvirdolic

@Bulan npm install is a temporary workaround. ng init should work without installing npm packages manually as previous versions did.

FabienDehopre avatar Sep 29 '16 15:09 FabienDehopre

I just want to add that performing ng init after npm install does not provide a list of diffs to the user. Angular-cli simply tells you:

It seems like you're using a project generated using an old version of the Angular CLI. The latest CLI now uses webpack and includes a lot of improvements, include a simpler workflow, a faster build and smaller bundles.

To get more info, including a step-by-step guide to upgrade the CLI, follow this link: https://github.com/angular/angular-cli/wiki/Upgrading-from-Beta.10-to-Beta.12

jjstreet avatar Sep 30 '16 16:09 jjstreet

Is this a bug that needs to be fixed? If so when will it be fixed?

norricorp avatar Oct 03 '16 12:10 norricorp

@FabienDehopre just to confirm, did you follow the whole procedure as indicated in https://github.com/angular/angular-cli#updating-angular-cli, including deleting node_modules and doing npm install --save-dev angular-cli@latest?

npm uninstall -g angular-cli
npm cache clean
npm install -g angular-cli@latest
rm -rf node_modules dist tmp
npm install --save-dev angular-cli@latest
ng init

filipesilva avatar Oct 09 '16 00:10 filipesilva

Hi Filipe, yes I did all of that and then got the error message on ng init. Regards,

------ Original Message ------ From: "Filipe Silva" [email protected] To: "angular/angular-cli" [email protected] Cc: "norricorp" [email protected]; "Manual" [email protected] Sent: 09/10/2016 01:07:22 Subject: Re: [angular/angular-cli] ng init cannot find @angular/core after update (#2410)

@FabienDehopre just to confirm, did you follow the whole procedure as indicated in https://github.com/angular/angular-cli#updating-angular-cli, including deleting node_modules and doing npm install --save-dev angular-cli@latest?

npm uninstall -g angular-cli npm cache clean npm install -g angular-cli@latest rm -rf node_modules dist tmp npm install --save-dev angular-cli@latest ng init — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

norricorp avatar Oct 09 '16 07:10 norricorp

@filipesilva yes, I did follow the whole update procedure. And I succeed to reproduce this issue on another project.

FabienDehopre avatar Oct 09 '16 09:10 FabienDehopre

I have the same issue when updating from .16 to .17 and yes I followed the update procedure.

angular-cli: 1.0.0-beta.17 node: 6.7.0 os: win32 x64

xtreemrage avatar Oct 09 '16 14:10 xtreemrage

Ok, just wanted to make sure since I'm having trouble reproducing this. This is what I did:

cd beta16-project # I keep a few versions around to test stuff
rm -rf node_modules dist tmp
npm install --save-dev angular-cli@latest
ng init

And just got the normal ng init output:

kamik@T460p MINGW64 /D/sandbox/beta16-project (master)
$ ng init
installing ng2
? Overwrite .editorconfig? (Yndh)

I don't understand how it's possible to get a Error: Cannot find module '@angular/core' error on at Object.<anonymous> (C:\Users\f.dehopre\devs\RnD\angular2\demo-app\angular2\node_modules\@ngtools\webpack\src\plugin.js:4:14) since all project dependencies should have been reinstalled on npm install --save-dev angular-cli@latest.

Are you maybe using a linked global install?

I'm sorry, I'm at a loss here :/

filipesilva avatar Oct 10 '16 14:10 filipesilva

@filipesilva start with a beta 15 project and see maybe?

Bulan avatar Oct 10 '16 15:10 Bulan

@Bulan for this scenario, there should be no difference between a beta.15 and a beta.17 project once you delete node_modules and the global CLI is at beta.17. Obviously there's something wrong though, so I'm asking for help.

Now I can spend 2 hours trying to repro this issue, which already has a workaround and doesn't seem to have a very big impact, trying every combination until I hit the bug. Or I can spend that time triaging and solving other issues and wait for a complete repro step that I can follow.

This repo generates a LOT of issues and it takes a long time going through all of them, so to optimize my time I tend to favor issues that I can quickly repro and debug.

filipesilva avatar Oct 10 '16 17:10 filipesilva

Good call, kill the big bugs first!

Bulan avatar Oct 10 '16 18:10 Bulan

See http://stackoverflow.com/questions/39780833/error-cannot-find-module-angular-core

JanStureNielsen avatar Oct 10 '16 22:10 JanStureNielsen

@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

FabienDehopre avatar Oct 11 '16 06:10 FabienDehopre

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

elvirdolic avatar Oct 11 '16 06:10 elvirdolic

Great job finding the problem @JanStureNielsen! We now have either ^ or ~ for anything on @angular/* that is stable, so this shouldn't happen on upgrades again.

filipesilva avatar Oct 14 '16 16:10 filipesilva

I get similar errors after attempting to follow instructions to update to the latest version of angular-cli. You mentioned a workaround for this ...what would that be ?

Thanks

Cannot find module '@angular/core' Error: Cannot find module '@angular/core' at Function.Module._resolveFilename (module.js:455:15) at Function.Module._load (module.js:403:25) at Module.require (module.js:483:17) at require (internal/module.js:20:19) at Object. (/Users/ageorge/HTML5/angular-tutorial/toh/node_modules/@ngtools/webpack/src/plugin.js:5:14) at Module._compile (module.js:556:32) at Object.Module._extensions..js (module.js:565:10) at Module.load (module.js:473:32) at tryModuleLoad (module.js:432:12)npm WARN @angular/[email protected]

On Mon, Oct 10, 2016 at 1:37 PM, Filipe Silva [email protected] wrote:

@Bulan https://github.com/Bulan for this scenario, there should be no difference between a beta.15 and a beta.17 project once you delete node_modules and the global CLI is at beta.17. Obviously there's something wrong though, so I'm asking for help.

Now I can spend 2 hours trying to repro this issue, which already has a workaround and doesn't seem to have a very big impact, trying every combination until I hit the bug. Or I can spend that time triaging and solving other issues and wait for a complete repro step that I can follow.

This repo generate a LOT of issues and it takes a long time going through all of them, so to optimize my time I tend to favor issues that I can quickly repro and debug.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/2410#issuecomment-252688211, or mute the thread https://github.com/notifications/unsubscribe-auth/AICCw9atXkH_5zCxI3Z-co2ZkYaFcnLjks5qynfRgaJpZM4KJrP6 .

viewstack avatar Oct 15 '16 15:10 viewstack