The error “node-sass: Command failed” occurs for multiple reasons:
- Using the deprecated
- Using a version of
node-sassthat is not compatible with your Node.js version.
- Using an outdated version of Create React app.
- Having a glitched
error /node_modules/node-sass: Command failed. Command: node scripts/build.js 1837 error command failed 1837 error gyp ERR! not ok 1837 error gyp info it worked if it ends with ok Exit code: 1
The two most common ways to solve the error are to:
- Install the
sasspackage instead of the deprecated
- Install a version of
node-sassthat is compatible with your version of Node.js.
The node-sass module has been deprecated, so the best way to solve the error is to use the sass module instead.
Open your terminal in your project’s root directory and run the following commands.
# 👇️ with NPM npm uninstall node-sass npm install sass --save-dev # 👇️ with YARN yarn remove node-sass yarn add sass --dev
The two commands uninstall the deprecated
node-sass module and install the
Try to restart your development server after running the commands.
# Delete your node_modules and reinstall your dependencies
If the error persists, try to delete your
node_modules and package-lock.json (not
package.json) files, rerun the
npm install command and restart your dev server.