An unhandled exception occurred: Cannot find module '@angular-devkit/core'
π Bug report
Command (mark with an x)
- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [x] 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. (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. (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
@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?
Bit of odd version info, I wasn't expecting the two 9.0.1 (cli-only) listed there. Do you have @angular-devkit/core listed in your package.json?
Can you also show me the result of npm list @angular-devkit/core and npm list @schematics/angular please?
[email protected] C:\Users\Giacomo\Documents\Progetti\Angular\forMca
+-- UNMET DEPENDENCY @angular-devkit/[email protected]
|
-- UNMET DEPENDENCY @angular-devkit/[email protected]
+-- UNMET DEPENDENCY @angular/[email protected]
| +-- UNMET DEPENDENCY @angular-devkit/[email protected]
| | -- UNMET DEPENDENCY @angular-devkit/[email protected]
| +-- UNMET DEPENDENCY @angular-devkit/[email protected]
| +-- UNMET DEPENDENCY @angular-devkit/[email protected]
| | -- UNMET DEPENDENCY @angular-devkit/[email protected]
| +-- UNMET DEPENDENCY @schematics/[email protected]
| | -- UNMET DEPENDENCY @angular-devkit/[email protected]
| -- UNMET DEPENDENCY @schematics/[email protected]
| +-- UNMET DEPENDENCY @angular-devkit/[email protected]
| -- UNMET DEPENDENCY @angular-devkit/[email protected]
| -- UNMET DEPENDENCY @angular-devkit/[email protected]
-- UNMET DEPENDENCY @angular/[email protected]
+-- UNMET DEPENDENCY @angular-devkit/[email protected]
-- UNMET DEPENDENCY @schematics/[email protected]
-- UNMET DEPENDENCY @angular-devkit/[email protected]
npm ERR! missing: @angular-devkit/[email protected], required by [email protected] npm ERR! missing: @angular/[email protected], required by [email protected] npm ERR! missing: @angular/[email protected], required by [email protected] npm ERR! missing: @angular-devkit/[email protected], required by @angular-devkit/[email protected] npm ERR! missing: @angular-devkit/[email protected], required by @angular/[email protected] npm ERR! missing: @angular-devkit/[email protected], required by @angular/[email protected] npm ERR! missing: @angular-devkit/[email protected], required by @angular/[email protected] npm ERR! missing: @schematics/[email protected], required by @angular/[email protected] npm ERR! missing: @schematics/[email protected], required by @angular/[email protected] npm ERR! missing: @angular-devkit/[email protected], required by @angular-devkit/[email protected] npm ERR! missing: @angular-devkit/[email protected], required by @angular-devkit/[email protected] npm ERR! missing: @angular-devkit/[email protected], required by @schematics/[email protected] npm ERR! missing: @angular-devkit/[email protected], required by @schematics/[email protected] npm ERR! missing: @angular-devkit/[email protected], required by @schematics/[email protected] npm ERR! missing: @angular-devkit/[email protected], required by @angular-devkit/[email protected] npm ERR! missing: @angular-devkit/[email protected], required by @angular/[email protected] npm ERR! missing: @schematics/[email protected], required by @angular/[email protected] npm ERR! missing: @angular-devkit/[email protected], required by @schematics/[email protected]
PS C:\Users\Giacomo\Documents\Progetti\Angular\forMca> npm list @schematics/angular
[email protected] C:\Users\Giacomo\Documents\Progetti\Angular\forMca
+-- UNMET DEPENDENCY @angular/[email protected]
|
-- UNMET DEPENDENCY @schematics/[email protected]
-- UNMET DEPENDENCY @angular/[email protected]
`-- UNMET DEPENDENCY @schematics/[email protected]
npm ERR! missing: @angular/[email protected], required by [email protected] npm ERR! missing: @angular/[email protected], required by [email protected] npm ERR! missing: @schematics/[email protected], required by @angular/[email protected] npm ERR! missing: @schematics/[email protected], required by @angular/[email protected]
That's a lot of missing deps, things shouldn't even run like that... are you using yarn in your project maybe? If so, can you use yarn list instead of npm list please?
Sorry i'm not use npm install before i have recovery project. This is before update:
PS C:\Users\Giacomo\Documents\Progetti\Angular\forMca> npm list @schematics/angular
[email protected] C:\Users\Giacomo\Documents\Progetti\Angular\forMca
+-- @angular/[email protected]
|
-- @schematics/[email protected]
-- @angular/[email protected]
`-- @schematics/[email protected]
PS C:\Users\Giacomo\Documents\Progetti\Angular\forMca> npm list @angular-devkit/core
[email protected] C:\Users\Giacomo\Documents\Progetti\Angular\forMca
+-- @angular-devkit/[email protected]
| +-- @angular-devkit/[email protected]
| |
-- @angular-devkit/[email protected]
| +-- @angular-devkit/[email protected]
| | -- @angular-devkit/[email protected]
| +-- @angular-devkit/[email protected]
| -- @ngtools/[email protected]
| -- @angular-devkit/[email protected]
+-- @angular-devkit/[email protected]
| -- @angular-devkit/[email protected]
+-- @angular/[email protected]
| +-- @angular-devkit/[email protected]
| +-- @angular-devkit/[email protected]
| | -- @angular-devkit/[email protected] deduped
| +-- @schematics/[email protected]
| | -- @angular-devkit/[email protected] deduped
| -- @schematics/[email protected]
| +-- @angular-devkit/[email protected]
| -- @angular-devkit/[email protected]
| -- @angular-devkit/[email protected] deduped
-- @angular/[email protected]
+-- @angular-devkit/[email protected]
-- @schematics/[email protected]
`-- @angular-devkit/[email protected] deduped
Can you show me the dependencies and devDependencies in your package.json please?
"dependencies": {
"@angular-devkit/schematics": "^8.3.25",
"@angular/animations": "^8.2.14",
"@angular/cdk": "^8.2.3",
"@angular/cli": "^8.3.25",
"@angular/common": "^8.2.14",
"@angular/compiler": "^8.2.14",
"@angular/core": "^8.2.14",
"@angular/flex-layout": "^8.0.0-beta.27",
"@angular/forms": "^8.2.14",
"@angular/material": "^8.2.3",
"@angular/material-moment-adapter": "^8.2.3",
"@angular/platform-browser": "^8.2.14",
"@angular/platform-browser-dynamic": "^8.2.14",
"@angular/pwa": "^0.803.25",
"@angular/router": "^8.2.14",
"@angular/service-worker": "^8.2.14",
"@fortawesome/angular-fontawesome": "^0.5.0",
"@fortawesome/fontawesome-free": "^5.12.1",
"@fortawesome/fontawesome-svg-core": "^1.2.27",
"@fortawesome/free-regular-svg-icons": "^5.12.1",
"@fortawesome/free-solid-svg-icons": "^5.12.1",
"@geoman-io/leaflet-geoman-free": "^2.3.0",
"@ng-select/ng-select": "^3.7.2",
"@progress/kendo-angular-common": "^1.2.1",
"@progress/kendo-angular-pdf-export": "^2.0.2",
"@progress/kendo-drawing": "^1.6.0",
"@types/jspdf": "^1.3.3",
"algebra.js": "^0.2.6",
"bootstrap": "^4.4.1",
"core-js": "^3.6.4",
"datatables.net-dt": "^1.10.20",
"datatables.net-responsive-dt": "^2.2.3",
"default-passive-events": "^1.0.10",
"document-register-element": "^1.14.3",
"file-saver": "^2.0.2",
"hammerjs": "^2.0.8",
"html2canvas": "^1.0.0-rc.5",
"html2pdf": "0.0.11",
"imagesloaded": "^4.1.4",
"imask": "^5.2.1",
"jquery": "^3.4.1",
"jquery-ui": "^1.12.1",
"jspdf": "^1.5.3",
"leaflet": "^1.6.0",
"lity": "^2.4.0",
"mathjs": "^6.6.0",
"ml-matrix": "^6.4.1",
"moment": "^2.24.0",
"n2words": "^1.3.1",
"node-sass": "^4.13.1",
"owl.carousel": "^2.3.4",
"popper.js": "^1.16.1",
"qrcode": "^1.4.4",
"rxjs": "^6.5.4",
"select2": "^3.5.1",
"uuid": "^3.4.0",
"zone.js": "^0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.803.25",
"@angular/compiler-cli": "^8.2.14",
"@angular/language-service": "^8.2.14",
"@types/file-saver": "^2.0.1",
"@types/googlemaps": "^3.39.2",
"@types/jasmine": "^3.5.3",
"@types/jasminewd2": "^2.0.8",
"@types/jquery": "^3.3.32",
"@types/jqueryui": "^1.12.10",
"@types/leaflet": "^1.5.8",
"@types/node": "^12.12.25",
"@types/proj4": "^2.5.0",
"@types/uuid": "^3.4.7",
"codelyzer": "^5.2.1",
"jasmine-core": "^3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^4.4.1",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage-istanbul-reporter": "^2.1.1",
"karma-jasmine": "^3.1.0",
"karma-jasmine-html-reporter": "^1.5.2",
"protractor": "^6.0.0",
"rxjs-watcher": "^1.1.3",
"ts-node": "^8.6.2",
"tslint": "^5.20.1",
"typescript": "^3.5.3"
}
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:
- Remove
@angular-devkit/schematicsfrom thepackage.json - Delete the
node_modulesdirectory and any associated lock files (package-lock.jsonoryarn.lock) - reinstall (
npm installor equivalent for your package manager) - commit the new lock file and try the update
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).
Got similar issue but related to @angular-devkit/schematics
An unhandled exception occurred: Cannot find module '@angular-devkit/schematics'
@clydin suggestion solves this issue.
@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?
Had the same issue than @KingDarBoja with schematics. Manually installing the packages and then deleting them as stated by @Toso82 solved my issue
An unhandled exception occurred: Cannot find module '@angular-devkit/build-angular/package.json' Require stack:
- C:\Users\ELI\AppData\Roaming\npm\node_modules@angular\cli\node_modules@angular-devkit\architect\node\node-modules-architect-host.js
- C:\Users\ELI\AppData\Roaming\npm\node_modules@angular\cli\node_modules@angular-devkit\architect\node\index.js
- C:\Users\ELI\AppData\Roaming\npm\node_modules@angular\cli\models\architect-command.js
- C:\Users\ELI\AppData\Roaming\npm\node_modules@angular\cli\commands\serve-impl.js
- C:\Users\ELI\AppData\Roaming\npm\node_modules@angular\cli\node_modules@angular-devkit\schematics\tools\export-ref.js
- C:\Users\ELI\AppData\Roaming\npm\node_modules@angular\cli\node_modules@angular-devkit\schematics\tools\index.js
- C:\Users\ELI\AppData\Roaming\npm\node_modules@angular\cli\utilities\json-schema.js
- C:\Users\ELI\AppData\Roaming\npm\node_modules@angular\cli\models\command-runner.js
- C:\Users\ELI\AppData\Roaming\npm\node_modules@angular\cli\lib\cli\index.js
- C:\Users\ELI\AppData\Roaming\npm\node_modules@angular\cli\lib\init.js
- C:\Users\ELI\AppData\Roaming\npm\node_modules@angular\cli\bin\ng See "C:\Users\ELI\AppData\Local\Temp\ng-zTY9Wo\angular-errors.log" for further details.
just use npm update and try again
just use npm update and try again
got solved thanks @firegbn
i didnt got the solution @firegbn please tell me the correct solution
its comming after ng serve --o
Had this issue today after doing an update. Solution suggested by Toso82 worked.TY.
I had this issue: Error: Cannot find module '@angular-devkit/build-angular/package.json' Just typing:
npm cache clean --force
npm install
It works.
An unhandled exception occurred: Cannot find module '@angular-devkit/build-angular/package.json' Require stack:
- C:\Users\admin\AppData\Roaming\npm\node_modules@angular\cli\node_modules@angular-devkit\architect\node\node-modules-architect-host.js
- C:\Users\admin\AppData\Roaming\npm\node_modules@angular\cli\node_modules@angular-devkit\architect\node\index.js
- C:\Users\admin\AppData\Roaming\npm\node_modules@angular\cli\models\architect-command.js
- C:\Users\admin\AppData\Roaming\npm\node_modules@angular\cli\commands\serve-impl.js
- C:\Users\admin\AppData\Roaming\npm\node_modules@angular\cli\node_modules@angular-devkit\schematics\tools\export-ref.js
- C:\Users\admin\AppData\Roaming\npm\node_modules@angular\cli\node_modules@angular-devkit\schematics\tools\index.js
- C:\Users\admin\AppData\Roaming\npm\node_modules@angular\cli\utilities\json-schema.js
- C:\Users\admin\AppData\Roaming\npm\node_modules@angular\cli\models\command-runner.js
- C:\Users\admin\AppData\Roaming\npm\node_modules@angular\cli\lib\cli\index.js
- C:\Users\admin\AppData\Roaming\npm\node_modules@angular\cli\lib\init.js
- C:\Users\admin\AppData\Roaming\npm\node_modules@angular\cli\bin\ng See "C:\Users\admin\AppData\Local\Temp\ng-d6DRYF\angular-errors.log" for further details.
E:\angular_project\app1>ng serve --open
I am also having this same problem as I started following Get Started guide from angular.io
I have found a solution after 4 hours of brainstorming research on this issue.
Node Package Manager does not install devDependencies, whenever you run npm install sometimes on Windows OS. Rather what it does is that it installs all the dependencies. So you just have to copy the contents of DevDependencies to Dependencies in package.json, which will force the manager to install those libraries. After copying all the DevDependencies to Dependencies, just run the command npm install, then proceed with ng serve and BOOM its up and running!!!
I hope it helps.
Thank you π