angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.76k stars 11.97k forks source link

ng update fails with "Cannot find module '@angular-devkit/schematics'" #16392

Closed rokerkony closed 4 years ago

rokerkony commented 4 years ago

🐞 Bug report

Command (mark with an x)

Description

Hi there, after reading a tweet from Igor to test out the new RC of ng9 I tried it on our application. The update command is not able to be finished even with flag --force due to the log below.

πŸ”₯ Exception or Error


ng update @angular/core @angular/cli --next --force
The installed Angular CLI version is older than the latest pre-release 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 74 dependencies.
Fetching dependency metadata from registry...
                  Package "@angular/core" has a missing peer dependency of "tslib" @ "^1.10.0".
                  Package "@angular/compiler-cli" has a missing peer dependency of "tslib" @ "^1.10.0".
                  Package "@angular/compiler" has a missing peer dependency of "tslib" @ "^1.10.0".
                  Package "@angular/common" has a missing peer dependency of "tslib" @ "^1.10.0".
                  Package "@angular/animations" has a missing peer dependency of "tslib" @ "^1.10.0".
                  Package "@angular/platform-browser" has a missing peer dependency of "tslib" @ "^1.10.0".
                  Package "@angular/forms" has a missing peer dependency of "tslib" @ "^1.10.0".
                  Package "@angular/router" has a missing peer dependency of "tslib" @ "^1.10.0".
                  Package "@angular/platform-browser-dynamic" has a missing peer dependency of "tslib" @ "^1.10.0".
                  Package "@angular/service-worker" has a missing peer dependency of "tslib" @ "^1.10.0".
    Updating package.json with dependency @angular/cli @ "9.0.0-rc.5" (was "8.3.20")...
    Updating package.json with dependency @angular/core @ "9.0.0-rc.5" (was "8.2.14")...
    Updating package.json with dependency @angular/compiler-cli @ "9.0.0-rc.5" (was "8.2.14")...
    Updating package.json with dependency @angular/language-service @ "9.0.0-rc.5" (was "8.2.14")...
    Updating package.json with dependency @angular-devkit/build-angular @ "0.900.0-rc.5" (was "0.803.20")...
    Updating package.json with dependency @angular/compiler @ "9.0.0-rc.5" (was "8.2.14")...
    Updating package.json with dependency @angular/common @ "9.0.0-rc.5" (was "8.2.14")...
    Updating package.json with dependency @angular/animations @ "9.0.0-rc.5" (was "8.2.14")...
    Updating package.json with dependency @angular/platform-browser @ "9.0.0-rc.5" (was "8.2.14")...
    Updating package.json with dependency @angular/forms @ "9.0.0-rc.5" (was "8.2.14")...
    Updating package.json with dependency @angular/router @ "9.0.0-rc.5" (was "8.2.14")...
    Updating package.json with dependency @angular/platform-browser-dynamic @ "9.0.0-rc.5" (was "8.2.14")...
    Updating package.json with dependency @angular/service-worker @ "9.0.0-rc.5" (was "8.2.14")...
    Updating package.json with dependency typescript @ "3.6.4" (was "3.5.3")...
UPDATE package.json (5246 bytes)
βœ” Packages installed successfully.
** Executing migrations of package '@angular/cli' **

❯ Angular Workspace migration.
  Update an Angular CLI workspace to version 9.
UPDATE angular.json (8832 bytes)
UPDATE ngsw-config.json (1508 bytes)
UPDATE src/tsconfig.app.json (380 bytes)
UPDATE package.json (5243 bytes)
βœ” Packages installed successfully.
  Migration completed.

❯ Lazy loading syntax migration.
  Update lazy loading syntax to use dynamic imports.
  Migration completed.

An unhandled exception occurred: Cannot find module '@angular-devkit/schematics'
Require stack:
- /Users/konradcerny/Sites/Erento/frontend-som/node_modules/@angular/core/schematics/migrations/move-document/index.js
- /private/var/folders/zl/ltj48w2n2hgcptmp_fh69mkm0000gn/T/.ng-temp-packages-qjhg0F/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /private/var/folders/zl/ltj48w2n2hgcptmp_fh69mkm0000gn/T/.ng-temp-packages-qjhg0F/node_modules/@angular-devkit/schematics/tools/index.js
- /private/var/folders/zl/ltj48w2n2hgcptmp_fh69mkm0000gn/T/.ng-temp-packages-qjhg0F/node_modules/@angular/cli/utilities/json-schema.js
- /private/var/folders/zl/ltj48w2n2hgcptmp_fh69mkm0000gn/T/.ng-temp-packages-qjhg0F/node_modules/@angular/cli/models/command-runner.js
- /private/var/folders/zl/ltj48w2n2hgcptmp_fh69mkm0000gn/T/.ng-temp-packages-qjhg0F/node_modules/@angular/cli/lib/cli/index.js
- /private/var/folders/zl/ltj48w2n2hgcptmp_fh69mkm0000gn/T/.ng-temp-packages-qjhg0F/node_modules/@angular/cli/lib/init.js
- /private/var/folders/zl/ltj48w2n2hgcptmp_fh69mkm0000gn/T/.ng-temp-packages-qjhg0F/node_modules/@angular/cli/bin/ng
See "/private/var/folders/zl/ltj48w2n2hgcptmp_fh69mkm0000gn/T/ng-PMjFIi/angular-errors.log" for further details.

The angular-errors.log file content:


[error] Error: Cannot find module '@angular-devkit/schematics'
Require stack:
- /Users/konradcerny/Sites/Erento/frontend-som/node_modules/@angular/core/schematics/migrations/move-document/index.js
- /private/var/folders/zl/ltj48w2n2hgcptmp_fh69mkm0000gn/T/.ng-temp-packages-qjhg0F/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /private/var/folders/zl/ltj48w2n2hgcptmp_fh69mkm0000gn/T/.ng-temp-packages-qjhg0F/node_modules/@angular-devkit/schematics/tools/index.js
- /private/var/folders/zl/ltj48w2n2hgcptmp_fh69mkm0000gn/T/.ng-temp-packages-qjhg0F/node_modules/@angular/cli/utilities/json-schema.js
- /private/var/folders/zl/ltj48w2n2hgcptmp_fh69mkm0000gn/T/.ng-temp-packages-qjhg0F/node_modules/@angular/cli/models/command-runner.js
- /private/var/folders/zl/ltj48w2n2hgcptmp_fh69mkm0000gn/T/.ng-temp-packages-qjhg0F/node_modules/@angular/cli/lib/cli/index.js
- /private/var/folders/zl/ltj48w2n2hgcptmp_fh69mkm0000gn/T/.ng-temp-packages-qjhg0F/node_modules/@angular/cli/lib/init.js
- /private/var/folders/zl/ltj48w2n2hgcptmp_fh69mkm0000gn/T/.ng-temp-packages-qjhg0F/node_modules/@angular/cli/bin/ng
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at /Users/konradcerny/Sites/Erento/frontend-som/node_modules/@angular/core/schematics/migrations/move-document/index.js:19:26
    at /Users/konradcerny/Sites/Erento/frontend-som/node_modules/@angular/core/schematics/migrations/move-document/index.js:10:17
    at Object. (/Users/konradcerny/Sites/Erento/frontend-som/node_modules/@angular/core/schematics/migrations/move-document/index.js:16:3)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at new ExportStringRef (/private/var/folders/zl/ltj48w2n2hgcptmp_fh69mkm0000gn/T/.ng-temp-packages-qjhg0F/node_modules/@angular-devkit/schematics/tools/export-ref.js:18:25)
    at NodeModulesEngineHost._resolveReferenceString (/private/var/folders/zl/ltj48w2n2hgcptmp_fh69mkm0000gn/T/.ng-temp-packages-qjhg0F/node_modules/@angular-devkit/schematics/tools/node-module-engine-host.js:58:21)
    at NodeModulesEngineHost.createSchematicDescription (/private/var/folders/zl/ltj48w2n2hgcptmp_fh69mkm0000gn/T/.ng-temp-packages-qjhg0F/node_modules/@angular-devkit/schematics/tools/file-system-engine-host-base.js:173:34)

🌍 Your Environment


Angular CLI: 8.3.20
Node: 12.12.0
OS: darwin x64
Angular: 8.2.14
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.803.20
@angular-devkit/build-angular     0.803.20
@angular-devkit/build-optimizer   0.803.20
@angular-devkit/build-webpack     0.803.20
@angular-devkit/core              8.3.20
@angular-devkit/schematics        8.3.20
@angular/cli                      8.3.20
@angular/pwa                      0.803.20
@ngtools/webpack                  8.3.20
@schematics/angular               8.3.20
@schematics/update                0.803.20
rxjs                              6.5.3
typescript                        3.5.3
webpack                           4.39.2

I will try to be as helpful as possible, but no clue what more data I could provide atm.

LosD commented 4 years ago

I'm seeing what looks like exactly the same issue.

clydin commented 4 years ago

Can you provide the output of npm ls @angular-devkit/schematics from within the project?

rokerkony commented 4 years ago

of course

before ng update:

frontend-som@0.0.0 /Users/konradcerny/Sites/Erento/frontend-som
β”œβ”€β”¬ @angular/cli@8.3.20
β”‚ β”œβ”€β”€ @angular-devkit/schematics@8.3.20
β”‚ β”œβ”€β”¬ @schematics/angular@8.3.20
β”‚ β”‚ └── @angular-devkit/schematics@8.3.20  deduped
β”‚ └─┬ @schematics/update@0.803.20
β”‚   └── @angular-devkit/schematics@8.3.20  deduped
└─┬ @angular/pwa@0.803.20
  └── @angular-devkit/schematics@8.3.20  deduped

after ng update (of course which ends with error):

frontend-som@0.0.0 /Users/konradcerny/Sites/Erento/frontend-som
└─┬ @angular/cli@9.0.0-rc.5
  β”œβ”€β”€ @angular-devkit/schematics@9.0.0-rc.5
  β”œβ”€β”¬ @schematics/angular@9.0.0-rc.5
  β”‚ └── @angular-devkit/schematics@9.0.0-rc.5  deduped
  └─┬ @schematics/update@0.900.0-rc.5
    └── @angular-devkit/schematics@9.0.0-rc.5
LosD commented 4 years ago

@rokerkony In my case, the update seems to have actually worked, despite the error. I'm not sure if everything has been run through the migration scripts, but after running an npm install (mostly just in case), running ng serve worked perfectly. And it seems to have gotten rid of the Ivy problem I had on angular 8 (changed modules not working with pipes until restarting ng serve).

btw, I also used angular material, and updating that ended in the same way, but also seems to have migrated as it should.

rokerkony commented 4 years ago

in our case, unfortunately, only the following files have been changed:

    modified:   angular.json
    modified:   ngsw-config.json
    modified:   package-lock.json
    modified:   package.json
    modified:   src/tsconfig.app.json

and I believe there should be also other files modified in regards to ivy & other changes in v9

LosD commented 4 years ago

Hmmmmm, for Ivy itself, the only thing I'd expect it to do was remove angularCompilerOptions->enableIvy from tsconfig.app.json, and remove projects->your_app->architect->build->aot from angular.json if you already had Ivy enabled in Angular 8 (as Ivy is the default, so those would just be noise now).

Not sure how it will act if you weren't using Ivy already? If it disables Ivy, I'd expect it to only write to tsconfig.app.json to set enableIvy false. If it forces Ivy, I'd expect it to also change modules to remove the entryComponents (unneeded under Ivy. They don't seem to be a problem to keep there, though. Some inefficiencies, maybe?).

I don't think there's really any source code changes needed, unless you're using Angular Material and were using top-level imports.

Interestingly, my ngsw-config.json wasn't changed for the ng9 upgrade even though I'm using the service worker.

clydin commented 4 years ago

@rokerkony Prior to updating, can you trying removing both the node_modules folder and the package-lock.json file and then re-installing the packages (npm install)?

The underlying cause appears to be that the package in question for some reason was not hoisted by the package manager to a location that the @angular/core migrations could find it. This should ideally not be an issue and there is ongoing work to improve the migration infrastructure to prevent situations such as this from occurring. However, these improvements will not be available within the 9.0 timeframe.

rokerkony commented 4 years ago

@clydin I tried to do "full" reinstall but with the same result

but I investigated the app a bit further and I checked it even after an unsuccessful update and it seems to work I just had to manually add import '@angular/localize/init'; to polyfills.ts and install the @angular/localize which is still in rc.0, but it is already written in the guide so πŸ‘

to sum up, our app is working but the migration is still not working properly as it didn't finish around 4 steps or so...

LosD commented 4 years ago

@rokerkony @clydin I'm starting to see some weird stuff that may be related to the botched update. When I try to generate a new component (using ng generate component the-component-name, I get this error:

An unhandled exception occurred: Cannot find module '@schematics/angular/package.json'
Require stack:
- /home/dennis/Projects/easylife-app-client/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/node-module-engine-host.js
- /home/dennis/Projects/easylife-app-client/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/workflow/node-workflow.js
- /home/dennis/Projects/easylife-app-client/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/index.js
- /home/dennis/Projects/easylife-app-client/node_modules/@angular/cli/utilities/json-schema.js
- /home/dennis/Projects/easylife-app-client/node_modules/@angular/cli/models/command-runner.js
- /home/dennis/Projects/easylife-app-client/node_modules/@angular/cli/lib/cli/index.js
- /home/dennis/.npm-global/lib/node_modules/@angular/cli/lib/init.js
- /home/dennis/.npm-global/lib/node_modules/@angular/cli/bin/ng
See "/tmp/ng-6hjETy/angular-errors.log" for further details.

This does not happen in a new 9.0 project.

@rokerkony Have you tried to use the CLI to generate components (or, I suspect, any generator) after upgrading?

jonathonadams commented 4 years ago

@LosD I am experiencing the same behaviour.

I encountered the same error during running of the migrations.

An unhandled exception occurred: Cannot find module '@angular-devkit/schematics'

and now I receive the same error when trying to generate components etc

An unhandled exception occurred: Cannot find module '@schematics/angular/package.json'

Interestingly, I deleted the node_modules (and kept the package-lock.json) and ran npm i. I expected the errors to disappear but I still get the same result. Currently running 9.0.0-rc.5

LosD commented 4 years ago

@jadams88 Yep, same for me, nuking node_modules didn't help.

An interesting difference from a new project (though this is from memory, as I'm not at the computer now): the root node_modules contains @schematics/angular in the new project, which is not in the upgraded project. Instead, there's a @schematics.angular (note the dot) folder in the node_modules/@angular/cli/node_modules folder. That seems wrong, but I can't really find a package.json reason for it.

Maybe the package-lock.json file is messed up? I don't think I tried deleting that, actually, even though @clydin suggested that as a fix for the original problem, so I should have tried that.

Edit: Okay, either I remembered wrong, or it's different at my home office computer, though the effect is the same; on my home machine, it's in node_modules/@angular/cli/node_modules/@schematics/angular. I think the script is looking in the main node_modules folder.

But more importantly: Deletingpackage-lock.json DID fix the problem! πŸŽ‰ (edit-edit: however, there's been a .rc-6 release of core angular, so that might also be what fixed it)

clydin commented 4 years ago

The lock file is the controlling element for modern package managers. Only removing the node modules directory and then re-installing will cause the package manager to generate the same node modules directory that was previously present as this is defined within the lock file. If encountering package hoisting related issues such as this, the lock file must be deleted along with the node modules directory.

LosD commented 4 years ago

@clydin Ah, of course. I'm still used to lock files from other languages, where their purpose is only to ensure that all developers and deployments use the same versions, so I never considered that it also affects the tree.

blogcraft commented 4 years ago

I am trying to update from 8 to v9.0.0-rc.8 and get the same error. I deleted node_modules and lock file.

jonathonadams commented 4 years ago

@blogcraft Have a look here at the commit to address this

https://github.com/clydin/angular-cli/commit/5d6602161b3151da7330c3854c9c7cce4c291f12

Effectively temporarily installing β€˜@angular-devkit/schematicsβ€˜ yourself prior to the migrations, then uninstall it after should work

blogcraft commented 4 years ago

Thanks!

Installing @angular-devkit/schematics worked at first, then it required @angular-devkit/core

I installed it and then it required @schematics/angular/utility/ast-utils

After that migration worked

arlowhite commented 4 years ago

@clydin @alan-agius4 I'm getting this issue updating from Angular 8.2.14 to 9.0 (angular/cli 8.3.25 to 9.0.1)

Should this issue be re-opened, or should I file a new issue? I can provide more details if needed. My project's fairly simple, I created it with angular/cli@8.2, the only additional dependencies are @angular/material and luxon

$ ng update @angular/cli @angular/core

Your global Angular CLI version (9.0.1) is greater than your local
version (8.3.25). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
The installed 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 36 dependencies.
Fetching dependency metadata from registry...
    Updating package.json with dependency @angular/cli @ "9.0.1" (was "8.3.25")...
    Updating package.json with dependency @angular/core @ "9.0.0" (was "8.2.14")...
    Updating package.json with dependency @angular-devkit/build-angular @ "0.900.1" (was "0.803.25")...
    Updating package.json with dependency @angular/compiler-cli @ "9.0.0" (was "8.2.14")...
    Updating package.json with dependency @angular/language-service @ "9.0.0" (was "8.2.14")...
    Updating package.json with dependency @angular/common @ "9.0.0" (was "8.2.14")...
    Updating package.json with dependency @angular/router @ "9.0.0" (was "8.2.14")...
    Updating package.json with dependency @angular/forms @ "9.0.0" (was "8.2.14")...
    Updating package.json with dependency @angular/animations @ "9.0.0" (was "8.2.14")...
    Updating package.json with dependency zone.js @ "0.10.2" (was "0.9.1")...
    Updating package.json with dependency typescript @ "3.7.5" (was "3.5.3")...
    Updating package.json with dependency @angular/platform-browser-dynamic @ "9.0.0" (was "8.2.14")...
    Updating package.json with dependency @angular/compiler @ "9.0.0" (was "8.2.14")...
    Updating package.json with dependency @angular/platform-browser @ "9.0.0" (was "8.2.14")...
    Updating package.json with dependency @angular/service-worker @ "9.0.0" (was "8.2.14")...
UPDATE package.json (1541 bytes)
βœ” Packages installed successfully.
** Executing migrations of package '@angular/cli' **

β–Έ Angular Workspace migration.
  Update an Angular CLI workspace to version 9.
UPDATE angular.json (4020 bytes)
UPDATE tsconfig.app.json (272 bytes)
UPDATE package.json (1511 bytes)
βœ” Packages installed successfully.
  Migration completed.

β–Έ Lazy loading syntax migration.
  Update lazy loading syntax to use dynamic imports.
  Migration completed.

An unhandled exception occurred: Cannot find module '@angular-devkit/schematics'
Require stack:
- /home/awhite/Code/MyHome/node_modules/@angular/core/schematics/migrations/move-document/index.js
- /tmp/.ng-temp-packages-18FkAV/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /tmp/.ng-temp-packages-18FkAV/node_modules/@angular-devkit/schematics/tools/index.js
- /tmp/.ng-temp-packages-18FkAV/node_modules/@angular/cli/utilities/json-schema.js
- /tmp/.ng-temp-packages-18FkAV/node_modules/@angular/cli/models/command-runner.js
- /tmp/.ng-temp-packages-18FkAV/node_modules/@angular/cli/lib/cli/index.js
- /tmp/.ng-temp-packages-18FkAV/node_modules/@angular/cli/lib/init.js
- /tmp/.ng-temp-packages-18FkAV/node_modules/@angular/cli/bin/ng
See "/tmp/ng-681DTk/angular-errors.log" for further details.

/tmp/ng-681DTk/angular-errors.log

[error] Error: Cannot find module '@angular-devkit/schematics'
Require stack:
- /home/awhite/Code/MyHome/node_modules/@angular/core/schematics/migrations/move-document/index.js
- /tmp/.ng-temp-packages-18FkAV/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /tmp/.ng-temp-packages-18FkAV/node_modules/@angular-devkit/schematics/tools/index.js
- /tmp/.ng-temp-packages-18FkAV/node_modules/@angular/cli/utilities/json-schema.js
- /tmp/.ng-temp-packages-18FkAV/node_modules/@angular/cli/models/command-runner.js
- /tmp/.ng-temp-packages-18FkAV/node_modules/@angular/cli/lib/cli/index.js
- /tmp/.ng-temp-packages-18FkAV/node_modules/@angular/cli/lib/init.js
- /tmp/.ng-temp-packages-18FkAV/node_modules/@angular/cli/bin/ng
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
    at Function.Module._load (internal/modules/cjs/loader.js:686:27)
    at Module.require (internal/modules/cjs/loader.js:848:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at /home/awhite/Code/MyHome/node_modules/@angular/core/schematics/migrations/move-document/index.js:19:26
    at /home/awhite/Code/MyHome/node_modules/@angular/core/schematics/migrations/move-document/index.js:10:17
    at Object.<anonymous> (/home/awhite/Code/MyHome/node_modules/@angular/core/schematics/migrations/move-document/index.js:16:3)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Module.require (internal/modules/cjs/loader.js:848:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at new ExportStringRef (/tmp/.ng-temp-packages-18FkAV/node_modules/@angular-devkit/schematics/tools/export-ref.js:18:25)
    at NodeModulesEngineHost._resolveReferenceString (/tmp/.ng-temp-packages-18FkAV/node_modules/@angular-devkit/schematics/tools/node-module-engine-host.js:58:21)
    at NodeModulesEngineHost.createSchematicDescription (/tmp/.ng-temp-packages-18FkAV/node_modules/@angular-devkit/schematics/tools/file-system-engine-host-base.js:173:34)

Reset my project to show state before:
git reset --hard; rm node_modules; npm i ng version

Angular CLI: 8.3.25
Node: 12.14.1
OS: linux x64
Angular: 8.2.14
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.803.25
@angular-devkit/build-angular     0.803.25
@angular-devkit/build-optimizer   0.803.25
@angular-devkit/build-webpack     0.803.25
@angular-devkit/core              8.3.22
@angular-devkit/schematics        8.3.22
@angular/cdk                      8.2.3
@angular/cli                      8.3.25
@angular/material                 8.2.3
@angular/pwa                      0.803.22
@ngtools/webpack                  8.3.25
@schematics/angular               8.3.22
@schematics/update                0.803.25
rxjs                              6.5.4
typescript                        3.5.3
webpack                           4.39.2

$ npm ls @angular-devkit/schematics

my-home@0.0.0 /home/awhite/Code/MyHome
β”œβ”€β”¬ @angular/cli@8.3.25
β”‚ β”œβ”€β”€ @angular-devkit/schematics@8.3.25 
β”‚ β”œβ”€β”¬ @schematics/angular@8.3.25
β”‚ β”‚ └── @angular-devkit/schematics@8.3.25  deduped
β”‚ └─┬ @schematics/update@0.803.25
β”‚   └── @angular-devkit/schematics@8.3.25 
└─┬ @angular/pwa@0.803.22
  β”œβ”€β”€ @angular-devkit/schematics@8.3.22 
  └─┬ @schematics/angular@8.3.22
    └── @angular-devkit/schematics@8.3.22  deduped
arlowhite commented 4 years ago

@clydin , I tried this advice:

[try] removing both the node_modules folder and the package-lock.json file and then re-installing the packages (npm install)?

But still get the error.

https://stackoverflow.com/a/58111309 I tried just: npm i @angular-devkit/schematics

β–Έ Angular Workspace migration.
  Update an Angular CLI workspace to version 9.
    Package "@angular-devkit/schematics" found in the workspace package.json. This package typically does not need to be installed manually. If it is not being used by project code, it can be removed from the package.json.
UPDATE angular.json (4020 bytes)
UPDATE tsconfig.app.json (272 bytes)
UPDATE package.json (1555 bytes)
βœ” Packages installed successfully.
  Migration completed.

β–Έ Lazy loading syntax migration.
  Update lazy loading syntax to use dynamic imports.
  Migration completed.

An unhandled exception occurred: Cannot find module '@angular-devkit/core'
Require stack:
- /home/awhite/Code/MyHome/node_modules/@angular/core/schematics/utils/project_tsconfig_paths.js
- /home/awhite/Code/MyHome/node_modules/@angular/core/schematics/migrations/move-document/index.js
- /tmp/.ng-temp-packages-ubnNgz/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /tmp/.ng-temp-packages-ubnNgz/node_modules/@angular-devkit/schematics/tools/index.js
- /tmp/.ng-temp-packages-ubnNgz/node_modules/@angular/cli/utilities/json-schema.js
- /tmp/.ng-temp-packages-ubnNgz/node_modules/@angular/cli/models/command-runner.js
- /tmp/.ng-temp-packages-ubnNgz/node_modules/@angular/cli/lib/cli/index.js
- /tmp/.ng-temp-packages-ubnNgz/node_modules/@angular/cli/lib/init.js
- /tmp/.ng-temp-packages-ubnNgz/node_modules/@angular/cli/bin/ng
See "/tmp/ng-g6oHQs/angular-errors.log" for further details.

Reset again, installed core too: npm i @angular-devkit/core

Update succeeds, with commentary on these packages:

β–Έ Angular Workspace migration.
  Update an Angular CLI workspace to version 9.
    Package "@angular-devkit/schematics" found in the workspace package.json. This package typically does not need to be installed manually. If it is not being used by project code, it can be removed from the package.json.
    Package "@angular-devkit/core" found in the workspace package.json. This package typically does not need to be installed manually. If it is not being used by project code, it can be removed from the package.json.
arlowhite commented 4 years ago

Same issue with @angular/material

$ ng update @angular/material
Using package manager: 'npm'
Collecting installed dependencies...
Found 37 dependencies.
Fetching dependency metadata from registry...
    Updating package.json with dependency @angular/material @ "9.0.0" (was "8.2.3")...
    Updating package.json with dependency @angular/cdk @ "9.0.0" (was "8.2.3")...
UPDATE package.json (1592 bytes)
βœ” Packages installed successfully.
An unhandled exception occurred: Cannot find module '@schematics/angular/utility/ast-utils'
Require stack:
- /home/awhite/Code/MyHome/node_modules/@angular/cdk/schematics/utils/ast.js
- /home/awhite/Code/MyHome/node_modules/@angular/cdk/schematics/utils/index.js
- /home/awhite/Code/MyHome/node_modules/@angular/cdk/schematics/index.js
- /home/awhite/Code/MyHome/node_modules/@angular/material/schematics/ng-update/index.js
- /home/awhite/Code/MyHome/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /home/awhite/Code/MyHome/node_modules/@angular-devkit/schematics/tools/index.js
- /home/awhite/Code/MyHome/node_modules/@angular/cli/utilities/json-schema.js
- /home/awhite/Code/MyHome/node_modules/@angular/cli/models/command-runner.js
- /home/awhite/Code/MyHome/node_modules/@angular/cli/lib/cli/index.js
- /home/awhite/.nvm/versions/node/v12.14.1/lib/node_modules/@angular/cli/lib/init.js
- /home/awhite/.nvm/versions/node/v12.14.1/lib/node_modules/@angular/cli/bin/ng
See "/tmp/ng-UxebB2/angular-errors.log" for further details.

Fixed by npm i @schematics/angular before update

blogcraft commented 4 years ago

https://github.com/angular/angular/issues/35221

somervda commented 4 years ago

I ran into same problems when upgrading from 8 to 9 , for all the same reasons. I followed the advise on this thread and was able to correct it by reloading my projects packages and adding the missing packages. If anyone is interested I made a video of what happened here https://youtu.be/ZCMGzo1D2_M skip forward to 5:34 for the steps that worked for me.

Cheers

angular-automatic-lock-bot[bot] commented 4 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.