Node-sass and sass-loader installation error

Usually when installing node-sass and sass-loader, various errors will be reported. Most of the installation failures are due to the version of node. Because the version of node is too high, it is not compatible with node-sass and sass-loader. Incompatibility, resulting in an error.

Installation usually has the following problems:
Problem 1:
TypeError: this.getOptions is not a function
insert image description here
Reasons and solutions: The sass configuration version is relatively high and is not compatible with the current node, so sass needs to be reduced to a stable version.
Solution steps:

1. Need to uninstall the original sass installation configuration
npm uninstall --save sass-loader // uninstall
npm uninstall --save node-sass // uninstall

2. Reinstall Sass and specify the version.
npm i -D [email protected] // install
npm i [email protected] // install

If the above operation still fails, uninstall the dependencies, find node-sass in package.json, manually change the version number to node-sass: "^4.14.1", and then npm install.

In most cases, you can reduce the node version to 12.14.0/12.14.1, reinstall node-sass and sass-loader, and the fault is solved

3. If you install node-sass, the error is reported as: Python executable python2 in the PATH

npm install reports error check python checking for Python executable python2 in the PATH
delete node_modules folder
in Terminal run npm install --global windows-build-tools --save
and then install npm install node-sass --save
to here, the error should be gone Solved, received gyp info ok prompt!
If you encounter Node Sass could not find a binding for your current environment, just run npm rebuild node-sass

Guess you like

Origin blog.csdn.net/weixin_47818125/article/details/127342901