Description
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