angular-cli: An unhandled exception occurred: Cannot find module '@angular-devkit/core'
π Bug report
Command (mark with an x
)
- new
- build
- serve
- test
- e2e
- generate
- add
- update
- xi18n
- lint
- run
- config
- help
- version
- doc
Is this a regression?
Description
Update my project from angular cli 8.3.25 to latest version
π¬ Minimal Reproduction
ng update @angular/cli @angular/core
π₯ Exception or Error
[error] Error: Cannot find module '@angular-devkit/core'
Require stack:
- C:\Users\Giacomo\Documents\Progetti\Angular\forMca\node_modules\@angular\core\schematics\utils\project_tsconfig_paths.js
- C:\Users\Giacomo\Documents\Progetti\Angular\forMca\node_modules\@angular\core\schematics\migrations\move-document\index.js
- C:\Users\Giacomo\AppData\Local\Temp\.ng-temp-packages-4EE2gk\node_modules\@angular\cli\node_modules\@angular-devkit\schematics\tools\export-ref.js
- C:\Users\Giacomo\AppData\Local\Temp\.ng-temp-packages-4EE2gk\node_modules\@angular\cli\node_modules\@angular-devkit\schematics\tools\index.js
- C:\Users\Giacomo\AppData\Local\Temp\.ng-temp-packages-4EE2gk\node_modules\@angular\cli\utilities\json-schema.js
- C:\Users\Giacomo\AppData\Local\Temp\.ng-temp-packages-4EE2gk\node_modules\@angular\cli\models\command-runner.js
- C:\Users\Giacomo\AppData\Local\Temp\.ng-temp-packages-4EE2gk\node_modules\@angular\cli\lib\cli\index.js
- C:\Users\Giacomo\AppData\Local\Temp\.ng-temp-packages-4EE2gk\node_modules\@angular\cli\lib\init.js
- C:\Users\Giacomo\AppData\Local\Temp\.ng-temp-packages-4EE2gk\node_modules\@angular\cli\bin\ng
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
at Function.Module._load (internal/modules/cjs/loader.js:862:27)
at Module.require (internal/modules/cjs/loader.js:1040:19)
at require (internal/modules/cjs/helpers.js:72:18)
at C:\Users\Giacomo\Documents\Progetti\Angular\forMca\node_modules\@angular\core\schematics\utils\project_tsconfig_paths.js:19:20
at C:\Users\Giacomo\Documents\Progetti\Angular\forMca\node_modules\@angular\core\schematics\utils\project_tsconfig_paths.js:10:17
at Object.<anonymous> (C:\Users\Giacomo\Documents\Progetti\Angular\forMca\node_modules\@angular\core\schematics\utils\project_tsconfig_paths.js:16:3)
at Module._compile (internal/modules/cjs/loader.js:1151:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1040:19)
at require (internal/modules/cjs/helpers.js:72:18)
at C:\Users\Giacomo\Documents\Progetti\Angular\forMca\node_modules\@angular\core\schematics\migrations\move-document\index.js:22:38
at C:\Users\Giacomo\Documents\Progetti\Angular\forMca\node_modules\@angular\core\schematics\migrations\move-document\index.js:10:17
at Object.<anonymous> (C:\Users\Giacomo\Documents\Progetti\Angular\forMca\node_modules\@angular\core\schematics\migrations\move-document\index.js:16:3)
π Your Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ β³ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 9.0.1
Node: 13.7.0
OS: win32 x64
Angular: 9.0.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker
Ivy Workspace: Yes
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.900.1
@angular-devkit/build-angular 0.900.1
@angular-devkit/build-optimizer 0.900.1
@angular-devkit/build-webpack 0.900.1
@angular-devkit/core 9.0.1 (cli-only)
@angular-devkit/schematics 9.0.1
@angular/cdk 8.2.3
@angular/cli 9.0.1
@angular/flex-layout 8.0.0-beta.27
@angular/material 8.2.3
@angular/material-moment-adapter 8.2.3
@angular/pwa <error>
@ngtools/webpack 9.0.1
@schematics/angular 9.0.1 (cli-only)
@schematics/update 0.900.1
rxjs 6.5.4
typescript 3.7.5
webpack 4.41.2
Anything else relevant?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 27 (4 by maintainers)
Commits related to this issue
- + solving https://github.com/angular/angular-cli/issues/16868#issuecomment-583723830 — committed to nodm/the-weather by nodm 4 years ago
- - solving https://github.com/angular/angular-cli/issues/16868#issuecomment-583723830 — committed to nodm/the-weather by nodm 4 years ago
- Temp fix for An unhandled exception occurred: Cannot find module '@angular-devkit/core https://github.com/angular/angular-cli/issues/16868 — committed to by-pinja/ngx-resource-calendar by samikaur 4 years ago
@clydin I solve with second solution:
- Install temporany latest version
npm install -D @schematics/angular @angular-devkit/core @angular-devkit/schematics
- Update angular
ng update @angular/cli @angular/core
- Remove package
npm uninstall @angular-devkit/schematics @schematics/angular @angular-devkit/core
But i donβt know what happen cold be something in global installation angular?
just use npm update and try again
It appears that the package manager is placing some of the dependencies required by the migrations within
@angular/core
(and potentially@angular/material
) in locations that are not resolvable to these migrations.As a first step to attempt to remedy the situation, can you try the following:
@angular-devkit/schematics
from thepackage.json
node_modules
directory and any associated lock files (package-lock.json
oryarn.lock
)npm install
or equivalent for your package manager)If this does not work then you may need to temporarily install the latest versions of
@schematics/angular
,@angular-devkit/core
, and@angular-devkit/schematics
prior to the update. And then remove them afterwards. (npm install -D @schematics/angular
/npm install -D @angular-devkit/core
/npm install -D @angular-devkit/schematics
).Just got the same issue, upgrading from version 10.0.8 to latest 11.0.2 @clydin 's solution worked (the second one:
npm install --save-dev @schematics/angular @angular-devkit/core @angular-devkit/schematics
, then doing theng update @angular/cli @angular/core
, and then uninstalling those 3 above)And now I get more files updated by the migration (in my case: all the spec files - it adds
waitForAsync
- and the main/root routing config - it addsrelativeLinkResolution: 'legacy'
). Before, with the error, it was only updating tsconfig files of apps and libs and the angular.json fileAn unhandled exception occurred: Cannot find module β@angular-devkit/build-angular/package.jsonβ Require stack:
issue solved TY toso82 unistalling and updating pakage did the trick for me
I had this issue: Error: Cannot find module β@angular-devkit/build-angular/package.jsonβ Just typing:
npm cache clean --force
npm install
It works.
You can run the command below
npm install --save-dev @angular-devkit/build-angular
OR check other answers from an unhandled exception occurred: cannot find module β@angular-devkit/build-angular/package.jsonβ
Had this issue today after doing an update. Solution suggested by Toso82 worked.TY.
Had the same issue than @KingDarBoja with schematics. Manually installing the packages and then deleting them as stated by @Toso82 solved my issue