Recently, when I compile my scss files I get an error. The error message says:
Browserslist: caniuse-lite is outdated. Please run next command
n
I had same problem too this command works for me
npm i autoprefixer@latest
It automatically added need dependency in package.json
and package-lock.json
file like below:
package.json
"autoprefixer": "^9.6.5",
package-lock.json
"@angular-devkit/build-angular": {
...
"dependencies": {
"autoprefixer": {
"version": "9.4.6",
"resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-9.4.6.tgz",
"integrity": "sha512-Yp51mevbOEdxDUy5WjiKtpQaecqYq9OqZSL04rSoCiry7Tc5I9FEyo3bfxiTJc1DfHeKwSFCUYbBAiOQ2VGfiw==",
"dev": true,
"requires": {
"browserslist": "^4.4.1",
"caniuse-lite": "^1.0.30000929",
"normalize-range": "^0.1.2",
"num2fraction": "^1.2.2",
"postcss": "^7.0.13",
"postcss-value-parser": "^3.3.1"
}
},
...
}
...
"autoprefixer": {
"version": "9.6.5",
"resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-9.6.5.tgz",
"integrity": "sha512-rGd50YV8LgwFQ2WQp4XzOTG69u1qQsXn0amww7tjqV5jJuNazgFKYEVItEBngyyvVITKOg20zr2V+9VsrXJQ2g==",
"requires": {
"browserslist": "^4.7.0",
"caniuse-lite": "^1.0.30000999",
"chalk": "^2.4.2",
"normalize-range": "^0.1.2",
"num2fraction": "^1.2.2",
"postcss": "^7.0.18",
"postcss-value-parser": "^4.0.2"
},
...
}
As mentioned in Scott Kuhl's answer this issue is mentioned in https://github.com/madskristensen/WebCompiler/issues/413
For me, running the command npm i caniuse-lite- browserslist
only worked for about 1/2 a day before it was an issue again.
The following solution, mentioned in the post, works much better. This updates the node.js file so that it uses console.log
instead of console.warn
when returning these errors.
You can manually update this file located at C:\Users\[Username]\AppData\Local\Temp\WebCompiler[VersionNumber]\node_modules\browserslist
Or, so that it is done automatically, add the following to your .csproj file by:
</Project>
end tag and before the build web compiler package was imported. <ItemGroup>
<PackageReference Include="MSBuildTasks" Version="1.5.0.235">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<PropertyGroup>
<TempFolder>$([System.IO.Path]::GetTempPath())</TempFolder>
</PropertyGroup>
<ItemGroup>
<BrowsersListNodeJsFiles Include="$(TempFolder)\WebCompiler*\node_modules\browserslist\node.js" />
</ItemGroup>
<Target Name="BrowsersListWarningsAsInfo" BeforeTargets="WebCompile">
<FileUpdate Files="@(BrowsersListNodeJsFiles)"
Regex="console.warn"
ReplacementText="console.log" />
</Target>