Reputation: 22520
Config: macOS High Sierra, version 10.13.2, node:v8.1.2 npm:5.0.3 When I run npm start in my angularjs project I get this error:
ERROR in Cannot find module 'node-sass'
After this I run:
npm i node-sass
Now I get this error:
gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
Why won't npm install node-sass? How can I install node-sass?
Upvotes: 297
Views: 518281
Reputation: 10248
In my case I also had to perform:
npm install sass-loader
To fix the problem
Upvotes: 6
Reputation: 7081
Here's the solution:
sudo npm install --save-dev --unsafe-perm node-sass
Enjoy!
Edited to explain the options (from comments):
--save-dev is used so that your app is able to find the module in local node_modules. --save-dev adds package to devDependencies in package.json. --unsafe--perm is used to run install scripts as root. To avoid sudo, use nvm instead. --unsafe--perm is really not needed as sudo is already mentioned. So the command basically air tights the script to install node-sass at any cost.
Upvotes: 543
Reputation: 441
Exactly same issue i was also facing and i tried all above answers but could not resolve, Below is the command which fixed my problem.
npm install sass-loader sass webpack --save-dev
https://www.npmjs.com/package/sass-loader
Upvotes: 1
Reputation: 85
I had to uninstall then reinstall Xcode. That fixed the error for me.
Upvotes: 0
Reputation: 1985
Doing npm uninstall node-sass
and then npm i node-sass
did not work for me.
Solution worked for me is npm install --save-dev node-sass
.
Happy Coding..
Upvotes: 28
Reputation: 724
There seems to be an issue with the version "node-sass": "4.5.3"
, try updating to the latest version. Such as you could try adding ^
"node-sass": "^4.5.3"
for the latest version
Upvotes: 0
Reputation: 931
you must install node-sass in dev section of package.json
npm install --unsafe-perm node-sass --save-dev
Upvotes: 2
Reputation: 497
Try sudo npm install [email protected]
if your node version is 12.
Upvotes: 2
Reputation: 49694
I met same issue installing node-sass when I am on Node 12.9.0
Once switching to Node 10.19.0, the issue is gone.
Reference: https://github.com/sass/node-sass/issues/2632
Upvotes: 0
Reputation: 1846
I have fix this problem without installing node-sass by this command:
npm install [email protected] --no-save --unsafe-perm
Upvotes: 4
Reputation: 2322
I had the same error when installing dependencies in Angular. I've tried aforementioned techniques but none of them worked until I've deleted package-lock.json
which was previously created when running Node v11.
Now I'm using Node v12 so this is how I got resolved.
I repeat if you have package-lock.json
delete it, file and then install dependencies.
Upvotes: 2
Reputation: 189
This is what worked for me. I first uninstall node-sass. Then install it back.
npm uninstall node-sass
npm install --save-dev node-sass
Upvotes: 6
Reputation: 20279
My problem was that a webfilter didn't allow me to download the node-sass package, when I executed the command
npm i
After the installation of the Windows Build Tools
npm i -g windows-build-tools
it build node-sass
on it's own and now I can use it.
PS: I also installed Python 2.7.17 before, but I don't think that helped.
Upvotes: 2
Reputation: 440
just run this command in terminal, it will install latest version of node-sass
npm install node-sass
Upvotes: -3
Reputation: 2814
According to node-sass github page, supported node.js version vary release by release.
https://github.com/sass/node-sass
Example: Check the version of node you are running.
node -v
-> v12.0.0
you need node-sass v4.12+. so you can
npm install [email protected]
or if 4.12.0 is the latest
npm install node-sass@latest
(npm install node-sass
will install the latest version in many cases, but remember that it does not always install the latest(in this example 4.12.0) if dependency in package.json is written like ^3.0.0, ~4.11.0)
What's the difference between tilde(~) and caret(^) in package.json?
Lastly, using sudo with npm is not a good practice. Please refer to this article. https://medium.com/@ExplosionPills/dont-use-sudo-with-npm-still-66e609f5f92
Upvotes: 44
Reputation: 112
npm install --save-dev --unsafe-perm node-sass
This will do magic, you can use it with sudo
Upvotes: 1
Reputation: 6544
It failed for me because I was using the latest version of node (12.7.0) I then had to explicitly install the latest version of node-sass
with:
npm install [email protected]
Upvotes: 5
Reputation: 2968
node-sass is not being installed and it can be one of many reasons
You have not installed it
npm install node-sass --save-dev
You are having a permissions error
sudo npm install --save-dev --unsafe-perm node-sass
You had a memory issue because it tried to make it (build from c code in your platform),this applies to some platforms and node versions
node --max_old_space_size=8000 $(which npm) install node-sass --save-dev
Your node and npm versions are not compatible,which most probably generated a failure in the build process,
In this case use n or nvm to make sure you have the same version in the new and original environment, the one where it did work, as this is usually by using different versions in different environments
Upvotes: 7
Reputation: 404
I had a similar issue when I tried to run a project. First i uninstalled the current version
npm uninstall node-sass
Then i reinstalled to the latest version with
npm install node-sass
Upvotes: 0
Reputation: 11
You should try to check the log generated by npm install
.
I have faced the same issues, and I found the error that python2 is not found in the path (environment variable).
After installing Python, everything worked fine.
Upvotes: 1
Reputation: 2674
I checked the Node version in my local machine, which is v10.11.0
.
Then when I checked my development machine, where the error occurred, it had Node version V.10.8.0
.
Upgrading Node to v10.11.0
in my development machine fixed the issue.
Hope this helps.
Upvotes: 3
Reputation: 1172
I ran into this error while I was using Microsoft Visual Studio Code's integrated git terminal. For some weird reason VS code was not allowing me to install 'node-sass'. Then I used 'Git Bash' (which was installed with git) and ran the following command:
npm install node-sass
It worked for me. I don't know why & how it worked. If anyone has any explanation please let me know.
Upvotes: 1
Reputation: 31
I have also been facing this error. None of the above methods work for me. Please follow this as it worked for me.
For Installing node-sass in Ubuntu 16 via npm :-
You can install with npm 5.2.0 Version
If you are using nvm :-
nvm install 8.2.1 nvm use 8.2.1 npm install node-sass
If you are using npm separately then upgrade or downgrade npm version to 5.2.0
npm install node-sass
Upvotes: 1
Reputation: 548
npm install node-sass
will do the job in most of the cases, as it will add missing sass npm dependency module doesn't exist or it will overwrite previous crashed version.
For Mac Users use sudo
in front of above commands.
On Windows machines npm rebuild node-sass --force
may not work for some users because it's essentially saying, "please force npm to rebuild the sass node module for me". It will not work because that module doesn't exist.
Whenever you did npm install
to the initial installation, the sass module did not get installed, which is why this problem occurs.
Upvotes: 2
Reputation: 124
One of the cases is the post-install process fails. Right after node-sass is installed, the post-install script will be executed. It requires Python and a C++ builder for that process. The log 'gyp: No Xcode or CLT version detected!' maybe because it couldn't find any C++ builder. So try installing Python and any C++ builder then put their directories in environment variables so that npm can find them. (I come from Windows)
Upvotes: 3
Reputation: 21
If you run
npm install node-sass
and it still doesn't work remember to change permission to folder
Upvotes: 1