ERROR in Cannot find module 'node-sass'
- This error is for node-sass is not present ... to solve this just you want to run following command
npm install node-sass
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
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.