The error “error /node_modules/node-sass: Command failed” is an error that is invoked whenever you are coding in node.js and using some incompatibility node modules. Given below is the snippet of the error, which I found when I was using vue.js:
Invariant Violation ViewPropTypes has been removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types'
error /var/www/html/vue-storefront/node_modules/node-sass: Command failed.
I would like to share with you the steps I took to fix the “error /node_modules/node-sass: Command failed” in your python file:
Why “error /node_modules/node-sass: Command failed” error is seen?
The error, “error /node_modules/node-sass: Command failed” is seen because; you are using an old node-sass version as compared to your node version in your project file.
The detailed solution to fix the error “error /node_modules/node-sass: Command failed”, is given below.
How to fix the error, “error /node_modules/node-sass: Command failed”?
For simple fix of the error, you can try to install the latest version of node-sass in accordance with your latest version of node which you are using in your project file.
To fix the error, “error /node_modules/node-sass: Command failed”, follow one of the methods given depending if you an yarn user or a npm user:
Method 1: For npm user
To fix the error, “error /node_modules/node-sass: Command failed”, you will have to follow the below mentioned steps:
Step 1: In case your are in a Apple M1 Chip, you will have to run the terminal with Rosetta 2
. Optional, as this is necessary only if you have your Node version installed with Rosetta
Step 2: You will have to check your node-sass
version in the package.json
of your file and you will have to compare it with the following table:
NodeJS | Supported node-sass version | Node Module |
---|---|---|
Node 16 | 6.0+ | 93 |
Node 15 | 5.0+ | 88 |
Node 14 | 4.14+ | 83 |
Node 13 | 4.13+, <5.0 | 79 |
Node 12 | 4.12+ | 72 |
Node 11 | 4.10+, <5.0 | 67 |
Node 10 | 4.9+, <6.0 | 64 |
Node 8 | 4.5.3+, <5.0 | 57 |
Node <8 | <5.0 | <57 |
Step 3: The next step is to check your Node version with the following command: node --version
node --version
Step 4: Then, you will have to install the Nodejs version according with your node-sass. In case you are using NVM, run: nvm use DESIRED_VERSION
nvm use DESIRED_VERSION
Step 5: The next step would be to clean your old node_modules and delete the folder, or type the following command in your terminal: rm -rf node_modules
rm -rf node_modules
Step 6: Lastly you will have to run the following command: npm install
npm install
Method 2: For yarn user
To fix the error, “error /node_modules/node-sass: Command failed”, you will have to update your code by following steps given below:
You will have to upgrade your node-sass version to be the same as node version. With yarn you will have to run the below mentioned code:
yarn add node-sass
This should fix your error, “error /node_modules/node-sass: Command failed”.
Conclusion
To fix the error “error /node_modules/node-sass: Command failed”, you will have to install the latest version of node-sass in accordance with your latest version of node which you are using in your project file.