Cannot install dependencies due to mismatch between node-sass and node versions

Cannot install dependencies due to mismatch between node-sass and node versions

If the installation dependency fails and the error is about node-sass, it is likely that the node version conflicts with the current node-sass version. For example, if the node version is upgraded to 14, then the node-sass version should be upgraded to 5.0.0 (node-sass version 6.0.0 is required for node version 16), and the sass-loader version should be upgraded to 10.1.1 (vue2.0 does not 11.x versions of sass-loader are supported).

At this time, you must first uninstall node-sass and reinstall it. Since the installation of node-sass relies on a binary file binding.node, the download may be very slow, so you can set the source address before downloading (similar to npm and yarn source addresses) :

// linux、mac 下
npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass/ npm install node-sass
// window 下
npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass/

npm install node-sass

Then upgrade sass-loader to version 10.1.1

Just in case, rebuild the node-sass cache

npm rebuild node-sass

At this point, the project should be able to install dependencies and run normally.

Guess you like

Origin blog.csdn.net/weixin_46862327/article/details/129173973