BrowserslistError: Unknown version 67 of android
The thing that solved it for me was running
npx browserslist --update-db
in project root. This made changes to package-lock.json
updating versions of caniuse-lite
.
To give some context, I landed on this question because I was getting this error:
Compiling TypeScript sources through ngc
ERROR: Unknown version 80 of android
An unhandled exception occurred: Unknown version 80 of android
after I upgraded angular from 9.x.x to 10.x.x.
I was getting this error both on my dev machine and in CI, so removing node_modules
and package-lock.json
was not really an option.
I'm seeing this too... like you, deleting node_modules and re-running npm install did not work.
What did work, however, was deleting node_modules AND deleting package-lock.json, and then running npm i.
Try that...
Andrew
Try this:
1.Deleting the entire node_modules directory.
2.Deleting package-lock.json from the root directory.
3.Making sure the latest @angular-devkit projects were referenced in package.json:
"@angular-devkit/build-angular": "^0.801.3", "@angular-devkit/build-ng-packagr": "^0.801.3".
4.Close and reopen cmd window.
Running npm install.
This might be too late, but I'm gonna post how I solved the issue, because I ran into it very recently (late Feb. 2022), and I followed a different approach that resulted in minimal changes to my project.
I had a similar issue with a project downloaded from StackBlitz, but in my case the unknown version of android
was 97 instead of 67 or 80.
The browserslist
database was up to date, deleting the node_modules
directory and running npm install
did not change anything (checked by using a comparison tool), updating the project's dependencies caused even more trouble, and so did deleting package-lock.json
.
What worked in my case was specifying 98 as the target version of android
(instead of 97) in .browserslistrc
in the project's root directory (I actually had to create that file, as it didn't exist).
This is how I found out that version 98 works:
I first temporarily edited the code where the exception occurred (in node_modules\browserslist\index.js
). Right before the line that throws the exception, I inserted this statement:
if (name === 'android') {
return arguments.callee(context, name, (version - 1).toString())
}
to find the largest number less than 97 that is accepted. Then I ran npx browserslist
and found that version to be 4.
Dissatisfied, I tried larger version numbers by replacing the above snippet with this one:
if (name === 'android' && Number(version) < 200) {
return arguments.callee(context, name, (Number(version) + 1).toString())
}
and fortunately, 98 worked (verified by running npx browserslist
again).
So I undid my changes to the code, grabbed that output from npx browserslist
, and saved it in .browserslistrc
(I also had to exclude safari
due to another bug).
The ng build
command then proceeded successfully.