Node – sass is what

Node-sass is a library that binds Node.js to LibSass, the C version of sass, the popular stylesheet preprocessor. It allows users to compile.scSS files locally to CSS with incredible speed and automatically through connected middleware.

To put it bluntly, node-Sass is a must if you want to make good use of CSS preprocessors like Sass in your projects.

Interestingly, node-sass is no longer officially recommended, and Dart Sass is now recommended: sass-lang.com/dart-sass. Interested partners can understand.

For now, though, we’ll focus on Node-sass.

Possible errors during node-sass installation and their solutions

When we execute NPM install or NPM I node-sass, we may encounter some problems. At this time, we need to carefully check the contents of the error message and solve the problem according to the error message. Here is a list of error messages I encountered and their resolution.

\win32-x64-72\binding. Node is not a valid win32 application.

The binding file is not a valid Win32 application. This file cannot be used and needs to be replaced. But how to replace them?

According to the error message, this file is located in the node_mudoles folder of the project. This folder is automatically created by the installation dependencies. It is not possible to modify the files under it, so if you want to modify the Binding file, you first need to change its reference path.

According to the path information in the figure above, we know that there is a corresponding binding file in this folder under disk C, and we can modify this folder. To do this, create a.npmrc file in the directory where you want to install Node-sass and enter the configuration information:

# XXX is the username on your computer. 6.0.1 is the version of Node-Sass you installedSASS_BINARY_DIR = C: \ Users \ \ AppData XXX, Roaming, NPM - cache, node - sass \ 6.0.1Copy the code

After the.npmrc file is configured, try installing the Node-sass package again and you may encounter this error

As shown above, the binding file is still not a legitimate Win32 application after changing the path. I think this is where Node-sass fails. But don’t worry, read on and I’ll come up with a solution soon.

First of all, open this folder with false information. Next we will copy the new Binding file into this folder.

Note that there are several versions of Node-sass available. The latest version is 6.0.1. Each version supports different versions of Node.

Determine which version of Node-sass you want to install based on the local Node version on your computer, and then download the corresponding binding file from Github.

There are many binding files available for each version, so be sure to download the correct file as prompted by the error message. In the error message above, you can see that the win32-x64-72 binding file is used, so download the file shown in the image below.

Once the file is downloaded, copy it to the folder opened above, change its name to binding.node, and replace the binding.node file in that folder.

After that, install the Node-sass package again and you’ll be fine.

If you don’t want to configure a.npmrc file for each project, you can use the following command to set the global configuration parameters of NPM:

The value of the parameter should be set according to the actual path of your computer
npm config set SASS_BINARY_DIR="C: \ Users \ XXXX \ AppData \ Roaming, NPM - cache, node - sass, 6.0.1." "
Copy the code

Other node-sass errors

While installing Node-sass, you may encounter other problems and bugs. If you do, please share the error information and we will solve it together.