node-sass: Command failed when running npm install

in reactjs and vuejs on May 19, 2023
< Back

The error “node-sass: Command failed” occurs for multiple reasons:

  1. Using the deprecated node-sass module.
  2. Using a version of node-sass that is not compatible with your Node.js version.
  3. Using an outdated version of Create React app.
  4. Having a glitched node_modules directory.
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:

  1. Install the sass package instead of the deprecated node-sass module.
  2. Install a version of node-sass that 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 sass module.

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.

Categories: reactjs and vuejs

Cart (0)

  • Your cart is empty.
Close

Request For My Information

 
Close

Request For Account Deletion

Close

Request For Information Deletion

Close

General Request / Query To DPO