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

ng update migration 'Remove Browserslist configuration files that matches the Angular CLI default configuration.' fails with non-descript error when #24991

Closed
1 task
chpoit opened this issue Apr 11, 2023 · 2 comments · Fixed by #24998
Labels
area: @schematics/angular freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix

Comments

@chpoit
Copy link

chpoit commented Apr 11, 2023

Command

update

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

The ng update from version 14 to 15 migration fails with the following nondescript error if you have a node_modules "backup", for example node_modules2, folder in the project directory

This is technically "my fault", but it would be nice if we had a better description of what is going on, I had to add a bunch of logs to the cli code to figure out where and what made it fail.

Here is the specific error:

Remove Browserslist configuration files that matches the Angular CLI default configuration.
× Migration failed: Unknown browser query `basedir=$(dirname "$(echo "$0" | sed -e 's`. Maybe you are using old Browserslist or made typo in query.
  See "<logs>\angular-errors.log" for further details.

Minimal Reproduction

Arrange your directories in the following fashion:

├───angular-root-directory
│ ├───node_modules
│ ├───node_modules2
│ ├───src
│ ├───package.json
│ ├───angular.json
│ ├───tsconfig.json

And run the @angular/cli migrations with a command equivalent to this one:
ng update @angular/cli --from 14 --to 15 --migrate-only --allow-dirty --force

The node_modules2 directory must have the npm packages too.

The specific cause of the "crash" is the presence of the browserslist file in /node_modules2/.bin/ because line 80 of
@schematics\angular\migrations\update-15\remove-browserslist-config.js tries to parse the source of the browserslist executable
Here is "my" line 80: const { defaults: browsersListConfig, ...otherConfigs } = browserslist.parseConfig(tree.readText(path));

Exception or Error

Remove Browserslist configuration files that matches the Angular CLI default configuration.
× Migration failed: Unknown browser query `basedir=$(dirname "$(echo "$0" | sed -e 's`. Maybe you are using old Browserslist or made typo in query.
  See "<logs>\angular-errors.log" for further details.


Actual log:
[error] BrowserslistError: Unknown browser query `basedir=$(dirname "$(echo "$0" | sed -e 's`. Maybe you are using old Browserslist or made typo in query.
    at unknownQuery (<PROJECT_ROOT>\node_modules\browserslist\index.js:283:10)
    at Function.select (<PROJECT_ROOT>\node_modules\browserslist\index.js:1149:15)
    at <PROJECT_ROOT>\node_modules\browserslist\index.js:314:29
    at Array.reduce (<anonymous>)
    at resolve (<PROJECT_ROOT>\node_modules\browserslist\index.js:304:34)
    at browserslist (<PROJECT_ROOT>\node_modules\browserslist\index.js:406:21)
    at <PROJECT_ROOT>\node_modules\@schematics\angular\migrations\update-15\remove-browserslist-config.js:91:43
    at async callRuleAsync (<PROJECT_ROOT>\node_modules\@angular-devkit\schematics\src\rules\call.js:78:18)

Your Environment

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 15.2.5
Node: 16.20.0
Package Manager: npm 8.19.4
OS: win32 x64

Angular: 15.2.6
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, localize, material
... material-moment-adapter, platform-browser
... platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1100.7
@angular-devkit/build-angular   15.2.5
@angular-devkit/core            15.2.5
@angular-devkit/schematics      15.2.5
@angular/cli                    15.2.5
@angular/flex-layout            15.0.0-beta.42
@schematics/angular             15.2.5
rxjs                            6.6.3
typescript                      4.9.5

Anything else relevant?

No response

@alan-agius4
Copy link
Collaborator

Closed via #24998 (comment)

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: @schematics/angular freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Projects
None yet
2 participants