question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug(update): Cannot find module '@angular-devkit/core/src/workspace/json/reader'

See original GitHub issue

Reproduction

Use StackBlitz to reproduce your issue: https://stackblitz.com/fork/components-issue

Steps to reproduce:

  1. 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
telb99commented, Jan 12, 2021

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

1reaction
alan-agius4commented, Nov 23, 2020

Should we at least add @angular-devkit/schematics and @angular-devkit/core to our peerDependencies so that developers would at least get a warning that these need to be installed?

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

I guess an alternative is to break all of our schematics out into a separate package that has the correct dependencies.

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found