Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to install node-sass in my project [closed]

I am doing wes-bos Learn Node course. When I run npm start it shows - cannot find module node-sass. And when I try to run npm install node-sass --save, it gives me the following errors.

Errors

Errors

like image 490
sugandh_g Avatar asked Oct 01 '17 17:10

sugandh_g


People also ask

How do I resolve a node Sass problem?

Run `npm rebuild node-sass` to build the binding for your current environment. This can occur when you have compiled modules locally and checked the resulting node_modules folder into git before deploying. To fix this, we recommend removing the node_modules folder from your git repo and redeploying.

Is node Sass deprecated?

Warning: LibSass and Node Sass are deprecated. While they will continue to receive maintenance releases indefinitely, there are no plans to add additional features or compatibility with any new CSS or Sass features. Projects that still use it should move onto Dart Sass.

Why can't I install a node Sass file?

This is because the original binding.node cache is not consistent with the current node version. Follow the prompts NPM rebuild node sass or clear the cache and reinstall. If the installation fails, reinstall it. You may not have permission to delete the installed content.

How to set up Sass in your project?

Sass is a CSS preprocessor that makes writing CSS more efficient and in my opinion much easier. In this post, I'll show you how you can set up SASS in your project. 1. Create a package.json file When you run the command in your project folder, you'll get a series of questions like the package name, description, author, license, etc.

What happens when pull binding fails in Sass?

If the pull binding.node fails, node sass will try to compile the binding.node locally, which requires python. If you have solved the above situations, it will not happen in the local build.

What is the node Sass version number?

You can see that it includes node sass version number v4.13.0, platform Win32, architecture x64, and Node Module version 64. Node Module is a module of node. Its version number can be found in process.versions: As shown above, the module version of node10.15.3 is 64.


2 Answers

Uninstall node-sass: npm uninstall node-sass Delete package-lock.json, and clean the cache: npm cache clean --force, then do npm update, npm install, npm update. then again try to install node sass: npm install node-sass.

If this doesn't work, Try to rebuild node-sass:

npm rebuild node-sass

If that too doesn't work then i suggest to delete package-lock.json, node-modules and npm cache folder and do npm install , to install all your dependencies again. make sure you have a package.json file with all your dependencies listed.

The package-lock.json file has some issues(it doesn't update when package.json changes) as mentioned here:https://github.com/npm/npm/issues/16866 "Touching package.json by hand may make your package.json to be incompatible with package-lock.json". do npm update to update the package-lock.json file. to completely disable package-lock creation: npm config set package-lock false

Update (16 july 2022): As node-sass is depricated(https://www.npmjs.com/package/node-sass), it is recommended to use dart-sass instead and upgrade the node version to v16 at least.

like image 117
vikrant Avatar answered Oct 21 '22 03:10

vikrant


Try this

sudo npm install -g --unsafe-perm node-sass --save
like image 32
Kumar Avatar answered Oct 21 '22 02:10

Kumar