Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update(10.1): migration to remove solution style tsconfig is not run #18744

Open
Splaktar opened this issue Sep 9, 2020 · 8 comments
Open

update(10.1): migration to remove solution style tsconfig is not run #18744

Splaktar opened this issue Sep 9, 2020 · 8 comments

Comments

@Splaktar
Copy link
Member

@Splaktar Splaktar commented Sep 9, 2020

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

No

Description

Running ng update @angular/cli to update to v10.1.0 from v10.0.8 does not run the migration to remove solution style tsconfigs.

🔬 Minimal Reproduction

  1. ng update @angular/cli
Your global Angular CLI version (10.1.0) is greater than your local
version (10.0.8). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
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...
    Updating package.json with dependency @angular-devkit/build-angular @ "0.1001.0" (was "0.1000.8")...
    Updating package.json with dependency @angular/cli @ "10.1.0" (was "10.0.8")...
UPDATE package.json (3764 bytes)
✔ Packages installed successfully.
splaktar:xlts.dev splaktar$ npm i
npm WARN @angular/fire@6.0.0 requires a peer of @angular/common@^9.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/fire@6.0.0 requires a peer of @angular/core@^9.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/fire@6.0.0 requires a peer of @angular/platform-browser@^9.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/fire@6.0.0 requires a peer of @angular/platform-browser-dynamic@^9.0.0 but none is installed. You must install peer dependencies yourself.

removed 4 packages and audited 2828 packages in 12.241s

126 packages are looking for funding
  run `npm fund` for details

found 4 high severity vulnerabilities
  run `npm audit fix` to fix them, or `npm audit` for details
  1. Notice that there are no migrations run
  2. Check that tsconfig.base.json still exists

🔥 Exception or Error

None

🌍 Your Environment

Before


Angular CLI: 10.0.8
Node: 12.16.1
OS: darwin x64

Angular: 10.1.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.1000.8
@angular-devkit/build-angular     0.1000.8
@angular-devkit/build-optimizer   0.1000.8
@angular-devkit/build-webpack     0.1000.8
@angular-devkit/core              9.1.12
@angular-devkit/schematics        9.1.12
@angular/cdk                      10.1.3
@angular/cli                      10.0.8
@angular/fire                     6.0.0
@angular/material                 10.1.3
@ngtools/webpack                  10.0.8
@schematics/angular               9.1.12
@schematics/update                0.1000.8
rxjs                              6.6.2
typescript                        3.9.7
webpack                           4.43.0

After


Angular CLI: 10.1.0
Node: 12.16.1
OS: darwin x64

Angular: 10.1.0
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.1001.0 (cli-only)
@angular-devkit/build-angular     0.1001.0
@angular-devkit/build-optimizer   0.1001.0
@angular-devkit/build-webpack     0.1001.0
@angular-devkit/core              9.1.12
@angular-devkit/schematics        9.1.12
@angular/cdk                      10.1.3
@angular/fire                     6.0.0
@angular/material                 10.1.3
@ngtools/webpack                  10.1.0
@schematics/angular               9.1.12
@schematics/update                0.1001.0
rxjs                              6.6.2
typescript                        4.0.2
webpack                           4.44.1

Anything else relevant?
I'm not sure why it's showing 9.1.12 for @angular-devkit/core, @angular-devkit/schematics, and @schematics/angular.

Here's the output of npm ls @angular-devkit/core:

├─┬ @angular-devkit/architect@0.1000.8
 └── @angular-devkit/core@10.0.8 
├─┬ @angular-devkit/build-angular@0.1000.8
 ├─┬ @angular-devkit/architect@0.1000.8
  └── @angular-devkit/core@10.0.8  deduped
 ├─┬ @angular-devkit/build-webpack@0.1000.8
  ├─┬ @angular-devkit/architect@0.1000.8
   └── @angular-devkit/core@10.0.8  deduped
  └── @angular-devkit/core@10.0.8 
 ├── @angular-devkit/core@10.0.8 
 └─┬ @ngtools/webpack@10.0.8
   └── @angular-devkit/core@10.0.8 
├─┬ @angular/cli@10.0.8
 ├─┬ @angular-devkit/architect@0.1000.8
  └── @angular-devkit/core@10.0.8  deduped
 ├── @angular-devkit/core@10.0.8 
 ├─┬ @angular-devkit/schematics@10.0.8
  └── @angular-devkit/core@10.0.8  deduped
 ├─┬ @schematics/angular@10.0.8
  └── @angular-devkit/core@10.0.8  deduped
 └─┬ @schematics/update@0.1000.8
   ├── @angular-devkit/core@10.0.8 
   └─┬ @angular-devkit/schematics@10.0.8
     └── @angular-devkit/core@10.0.8  deduped
├─┬ @schuchard/prettier@3.1.0
 ├── @angular-devkit/core@7.3.9 
 └─┬ @angular-devkit/schematics@7.3.9
   └── @angular-devkit/core@7.3.9  deduped
└─┬ @scullyio/init@1.0.0-beta.0
  ├── @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

Here's the output of npm ls @schematics/angular:

├─┬ @angular/cli@10.0.8
│ └── @schematics/angular@10.0.8 
└─┬ @scullyio/init@1.0.0-beta.0
  ├── @schematics/angular@9.1.12 
  └─┬ schematics-utilities@2.0.2
    └── @schematics/angular@8.3.29 
@Splaktar
Copy link
Member Author

@Splaktar Splaktar commented Sep 9, 2020

I thought that perhaps Scully was causing issues since it had the older versions, but removing it actually resulted in an error (rather than things working properly):

$ ng update @angular/cli
Your global Angular CLI version (10.1.0) is greater than your local
version (10.0.8). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
The "@angular-devkit/schematics" package cannot be resolved from the workspace root directory. This may be due to an unsupported node modules structure.
Please remove both the "node_modules" directory and the package lock file; and then reinstall.
If this does not correct the problem, please temporarily install the "@angular-devkit/schematics" package within the workspace. It can be removed once the update is complete.
splaktar:xlts.dev splaktar$ npm ls @angular-devkit/schematics
xlts.dev@0.2.0 /Users/splaktar/Git/devintent/xlts/xlts.dev
├─┬ @angular/cli@10.0.8
│ ├── @angular-devkit/schematics@10.0.8 
│ ├─┬ @schematics/angular@10.0.8
│ │ └── @angular-devkit/schematics@10.0.8  deduped
│ └─┬ @schematics/update@0.1000.8
│   └── @angular-devkit/schematics@10.0.8 
└─┬ @schuchard/prettier@3.1.0
  └── @angular-devkit/schematics@7.3.9 
@Splaktar
Copy link
Member Author

@Splaktar Splaktar commented Sep 9, 2020

Workaround

With my Scully libs put back in and everything restored to the original state:

  1. rm -rf node_modules/
  2. rm package-lock.json
  3. npm i
  4. ng update @angular/cli
Your global Angular CLI version (10.1.0) is greater than your local
version (10.0.8). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
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.
Repository is not clean. Update changes will be mixed with pre-existing changes.
Using package manager: 'npm'
Collecting installed dependencies...
Found 54 dependencies.
Fetching dependency metadata from registry...
    Updating package.json with dependency @angular-devkit/build-angular @ "0.1001.0" (was "0.1000.8")...
    Updating package.json with dependency @angular/cli @ "10.1.0" (was "10.0.8")...
UPDATE package.json (3757 bytes)
✔ Packages installed successfully.
** Executing migrations of package '@angular/cli' **

❯ Removing "Solution Style" TypeScript configuration file support.
DELETE tsconfig.base.json
UPDATE tsconfig.json (795 bytes)
UPDATE tsconfig.spec.json (385 bytes)
UPDATE projects/angularjs.xlts.dev/tsconfig.app.json (190 bytes)
UPDATE projects/xlts.dev/tsconfig.app.json (190 bytes)
  Migration completed.
@Splaktar
Copy link
Member Author

@Splaktar Splaktar commented Sep 9, 2020

Questions

Can the situation with The "@angular-devkit/schematics" package cannot be resolved from the workspace root directory. be improved?

  • First it didn't find the latest version and used a version from a library that didn't match the version used by the CLI. There was no warning or error here. It seems like there should have been when doing ng update to 10.1 and the update using schematic libs from 9.1.
  • Second, it didn't find the schematics package when it was clearly visible to npm ls. Why? Is there a bug in this package resolution code?
@cwhaught
Copy link

@cwhaught cwhaught commented Sep 9, 2020

I am encountering a similar if not the same problem.

I have tsconfig.base.json(but no tsconfig.json) in the root of my project and get a failure of

[error] Error: Could not read 'tsconfig.json'.
    at new JSONFile (<path_to_repo>/node_modules/@schematics/angular/utility/json-file.js:22:19)

every time I try to run

ng update @angular/cli @angular/core

@Splaktar
Copy link
Member Author

@Splaktar Splaktar commented Sep 9, 2020

@cwhaught that seems like a separate issue. Can you please open a new issue for it?

@cwhaught
Copy link

@cwhaught cwhaught commented Sep 9, 2020

Apologies @Splaktar, I thought I saw the same error in your comments at first glance.

@alan-agius4
Copy link
Collaborator

@alan-agius4 alan-agius4 commented Sep 10, 2020

Hi @Splaktar,

Find below the answers to your questions, feel free to ask more 😀.

Can the situation with The "@angular-devkit/schematics" package cannot be resolved from the workspace root directory. be improved?

This should be handled with the new version of schematics, aka schematics runtime, which is still currently in it's early design phase.

  • First it didn't find the latest version and used a version from a library that didn't match the version used by the CLI. There was no warning or error here. It seems like there should have been when doing ng update to 10.1 and the update using schematic libs from 9.1.

Maybe we can issue a warning when the installed @angular/cli version and @schematics/angular mismatch.

  • Second, it didn't find the schematics package when it was clearly visible to npm ls. Why? Is there a bug in this package resolution code?

While npm ls does list @angular-devkit/schematics, none of these is directly under the root level node_modules directory. This resolution is intended, this is because certain packages with schematics will not have @angular-devkit/schematics as a direct dependency. One such package is @angular/core, in which case having the above node_module structure will cause failures when running ng update @angular/core. Te schematic runtime will handle such situation, however this concept is still in it's early design phase.

Side note: I'd suggest that a lock file maintain is done periodically. Overtime when packages are added and updated, the presence of a lock file will hinder package hoisting and deduping.

There are two quick ways to do such maintainance:

  1. If your project is on GitHub, enable Renovate bot lock file maintenance feature..
  2. Run rm -rf node_modules package-lock.json && npm i
@KingDarBoja
Copy link

@KingDarBoja KingDarBoja commented Oct 19, 2020

I ran the following command and it worked out:

ng update @angular/cli --from=10.0.0 --to=10.1.3 --migrateOnly=true

As I forgot to use ng update after updating my packages with npm-check-updates to latest CLI version (v10.1.3).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.