bug(update): Cannot find module '@angular-devkit/core/src/workspace/json/reader'
See original GitHub issueReproduction
Use StackBlitz to reproduce your issue: https://stackblitz.com/fork/components-issue
Steps to reproduce:
ng update @angular/core @angular/cli @angular/material --force
Expected Behavior
What behavior were you expecting to see?
- CDK Migrations run w/o exceptions.
Actual Behavior
What behavior did you actually see?
[error] Error: Cannot find module '@angular-devkit/core/src/workspace/json/reader'
Require stack:
- /Users/splaktar/Git/devintent/xlts/xlts.dev/node_modules/@angular/cdk/schematics/utils/project-tsconfig-paths.js
- /Users/splaktar/Git/devintent/xlts/xlts.dev/node_modules/@angular/cdk/schematics/ng-update/devkit-migration-rule.js
- /Users/splaktar/Git/devintent/xlts/xlts.dev/node_modules/@angular/cdk/schematics/ng-update/index.js
- /private/var/folders/mz/pjttw4vs5xs33pzstmq1h7140000gn/T/angular-cli-packages-JfwbdW/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /private/var/folders/mz/pjttw4vs5xs33pzstmq1h7140000gn/T/angular-cli-packages-JfwbdW/node_modules/@angular-devkit/schematics/tools/index.js
- /private/var/folders/mz/pjttw4vs5xs33pzstmq1h7140000gn/T/angular-cli-packages-JfwbdW/node_modules/@angular/cli/utilities/json-schema.js
- /private/var/folders/mz/pjttw4vs5xs33pzstmq1h7140000gn/T/angular-cli-packages-JfwbdW/node_modules/@angular/cli/models/command-runner.js
- /private/var/folders/mz/pjttw4vs5xs33pzstmq1h7140000gn/T/angular-cli-packages-JfwbdW/node_modules/@angular/cli/lib/cli/index.js
- /private/var/folders/mz/pjttw4vs5xs33pzstmq1h7140000gn/T/angular-cli-packages-JfwbdW/node_modules/@angular/cli/lib/init.js
- /private/var/folders/mz/pjttw4vs5xs33pzstmq1h7140000gn/T/angular-cli-packages-JfwbdW/node_modules/@angular/cli/bin/ng
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/Users/splaktar/Git/devintent/xlts/xlts.dev/node_modules/@angular/cdk/schematics/utils/project-tsconfig-paths.js:21:18)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/Users/splaktar/Git/devintent/xlts/xlts.dev/node_modules/@angular/cdk/schematics/ng-update/devkit-migration-rule.js:22:34)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
Environment
- Browser(s): Chrome 86
- Operating System (e.g. Windows, macOS, Ubuntu): macOS 10.15.7
Before running ng update @angular/core @angular/cli @angular/material --force
:
Angular CLI: 10.1.7
Node: 14.15.0
OS: darwin x64
Angular: 10.1.6
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1001.7
@angular-devkit/build-angular 0.1001.7
@angular-devkit/core 7.3.10
@angular-devkit/schematics 7.3.10
@angular/cdk 10.2.7
@angular/cli 10.1.7
@angular/fire 6.0.5
@angular/material 10.2.7
@schematics/angular 10.1.7
@schematics/update 0.1001.7
ng-packagr 10.1.2
rxjs 6.6.3
typescript 4.0.5
After running ng update @angular/core @angular/cli @angular/material --force
:
Angular CLI: 11.0.1
Node: 14.15.0
OS: darwin x64
Angular: 11.0.0
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, material, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1100.1
@angular-devkit/build-angular 0.1100.1
@angular-devkit/core 7.3.10
@angular-devkit/schematics 7.3.10
@angular/cli 11.0.1
@angular/fire 6.0.5
@schematics/angular 11.0.1
@schematics/update 0.1100.1
ng-packagr 11.0.2
rxjs 6.6.3
typescript 4.0.5
The CLI DevKit versions reported are v7 because of @schuchard/prettier
and some others are using v8 or v9 versions of CLI DevKit:
npm ls @angular-devkit/core
xlts.dev@0.3.0 /Users/splaktar/Git/devintent/xlts/xlts.dev
βββ¬ @angular-devkit/build-angular@0.1001.7
β βββ¬ @angular-devkit/architect@0.1001.7
β β βββ @angular-devkit/core@10.1.7
β βββ¬ @angular-devkit/build-webpack@0.1001.7
β β βββ @angular-devkit/core@10.1.7
β βββ @angular-devkit/core@10.1.7
β βββ¬ @ngtools/webpack@10.1.7
β βββ @angular-devkit/core@10.1.7
βββ¬ @angular/cli@10.1.7
β βββ @angular-devkit/core@10.1.7
β βββ¬ @angular-devkit/schematics@10.1.7
β β βββ @angular-devkit/core@10.1.7 deduped
β βββ¬ @schematics/angular@10.1.7
β β βββ @angular-devkit/core@10.1.7
β β βββ¬ @angular-devkit/schematics@10.1.7
β β βββ @angular-devkit/core@10.1.7 deduped
β βββ¬ @schematics/update@0.1001.7
β βββ @angular-devkit/core@10.1.7
β βββ¬ @angular-devkit/schematics@10.1.7
β βββ @angular-devkit/core@10.1.7 deduped
βββ¬ @schuchard/prettier@3.1.0
β βββ @angular-devkit/core@7.3.10
β βββ¬ @angular-devkit/schematics@7.3.10
β βββ @angular-devkit/core@7.3.10 deduped
βββ¬ @scullyio/init@1.0.1
βββ @angular-devkit/core@9.1.12
βββ¬ @angular-devkit/schematics@9.1.12
β βββ @angular-devkit/core@9.1.12 deduped
βββ¬ @schematics/angular@9.1.12
β βββ @angular-devkit/core@9.1.12 deduped
βββ¬ schematics-utilities@2.0.2
βββ @angular-devkit/core@8.3.29
βββ¬ @angular-devkit/schematics@8.3.29
β βββ @angular-devkit/core@8.3.29 deduped
βββ¬ @schematics/angular@8.3.29
β βββ @angular-devkit/core@8.3.29 deduped
βββ¬ @schematics/update@0.803.29
βββ @angular-devkit/core@8.3.29 deduped
It looks like the CDK is accessing the wrong version of the CLI DevKit SDK. I think that we had a similar problem in a previous release.
Command output:
$ ng update @angular/core @angular/cli @angular/material --allow-dirty --force
The installed local Angular CLI version is older than the latest stable version.
Installing a temporary version to perform the update.
Installing packages for tooling via npm.
Installed packages for tooling via npm.
Using package manager: 'npm'
Collecting installed dependencies...
Found 54 dependencies.
Fetching dependency metadata from registry...
Package "@angular-devkit/build-angular" has an incompatible peer dependency to "karma" (requires "~5.1.0", would install "5.2.3")
Updating package.json with dependency @angular-devkit/build-angular @ "0.1100.1" (was "0.1001.7")...
Updating package.json with dependency @angular/cli @ "11.0.1" (was "10.1.7")...
Updating package.json with dependency @angular/compiler-cli @ "11.0.0" (was "10.1.6")...
Updating package.json with dependency @angular/language-service @ "11.0.0" (was "10.1.6")...
Updating package.json with dependency ng-packagr @ "11.0.2" (was "10.1.2")...
Updating package.json with dependency @angular/animations @ "11.0.0" (was "10.1.6")...
Updating package.json with dependency @angular/cdk @ "11.0.0" (was "10.2.7")...
Updating package.json with dependency @angular/common @ "11.0.0" (was "10.1.6")...
Updating package.json with dependency @angular/compiler @ "11.0.0" (was "10.1.6")...
Updating package.json with dependency @angular/core @ "11.0.0" (was "10.1.6")...
Updating package.json with dependency @angular/forms @ "11.0.0" (was "10.1.6")...
Updating package.json with dependency @angular/material @ "11.0.0" (was "10.2.7")...
Updating package.json with dependency @angular/platform-browser @ "11.0.0" (was "10.1.6")...
Updating package.json with dependency @angular/platform-browser-dynamic @ "11.0.0" (was "10.1.6")...
Updating package.json with dependency @angular/router @ "11.0.0" (was "10.1.6")...
UPDATE package.json (3815 bytes)
β Packages installed successfully.
** Executing migrations of package '@angular/cli' **
β― Replace deprecated library builder '@angular-devkit/build-ng-packagr'.
Migration completed.
β― Add 'declarationMap' compiler options for non production library builds.
Migration completed.
β― Remove deprecated options from 'angular.json' that are no longer present in v11.
UPDATE angular.json (9080 bytes)
Migration completed.
β― Update workspace dependencies to match a new v11 project.
UPDATE package.json (3816 bytes)
β Packages installed successfully.
Migration completed.
An unhandled exception occurred: Cannot find module '@angular-devkit/core/src/workspace/json/reader'
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:12 (8 by maintainers)
Top Results From Across the Web
I get this error:Cannot find module '@angular-devkit/build ...
The error states that "Cannot find module '@angular-devkit/build-angular/package.json'" which means you have to have that package added.
Read more >Fixing Could not find module @angular-devkit/build-angular ...
To fix Could not find module angular-devkit-build-angular error in Angular follow the below steps 1. Delete node_modules folder and run npmΒ ...
Read more >Could not find module '@angular-devkit/build-angular'
To solve the error Could not find module '@angular-devkit/build-angular', make sure to install the package by opening your terminal in your project's rootΒ ......
Read more >Cannot find module '@angular-devkit/build-angular ... - YouTube
An unhandled exception occurred: Cannot find module '@ angular - devkit /build-angular/package.json'The above exception while running an angularΒ ...
Read more >Error: Cannot find module '@angular-devkit/core' - YouTube
Error: Cannot find module '@ angular - devkit /core'npm update did not resolve it earlier.From Filip SaviΔ ( new versions for your package.json...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Was able to get around this by installing @angular-devkit/core as a dev package with βnpm i -D @angular-devkit/core@10β and trying again
Adding them as peerDependency will require this packages to be installed and listed in the users package.json, which is not ideal. Users shouldnβt be exposed to the packages unless they are developing schematics themselves. Also with NPM 7, unmet peerDepedencies get installed by default and unmeet peer deps are now hard error https://github.com/npm/rfcs/blob/latest/implemented/0025-install-peer-deps.md
That can work, although I donβt think it should be a single package for all the migrations. I think it should be still separated by repo. Iβd also assume that this package will be installed by the schematic when the migration runs.
Note: all the above will only be needed until a new version ng-update is available.