How to fix 'Node Sass could not find a binding in your current env.' when running npm run build

Kyrylo Lukeniuk picture Kyrylo Lukeniuk · Apr 8, 2019 · Viewed 13.3k times · Source

I'm running sudo npm run build and it says that it cannot find binding for sass. I have currently installed only one version of npm and it's 11.13.0

I tried npm install node-sass, npm rebuild node-sass, npm uninstall -save node-sass, npm install -save node-sass, npm cache clean, removing competely node and node_modules folders, but still getting the same error. I did however have had version 8.0.0 installed, but I removed it using nvm

ERROR in ./src/main/webapp/styles/styles.scss (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./node_modules/sass-loader/lib/loader.js??ref--14-3!./src/main/webapp/styles/styles.scss)
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
Error: Missing binding /home/dev/IdeaProjects/web-project/node_modules/node-sass/vendor/linux-x64-57/binding.node
Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 8.x

Found bindings for the following environments:
  - Linux 64-bit with Node.js 11.x

If you need any additional information please let me know.

Answer

Kinman picture Kinman · Apr 20, 2019

This is due to a mismatch between the version of node used in your project and what you have globally installed.

  1. Review the version of node indicated in your project's package.json
  2. Change the version to the desired version of node
  3. Clear the project's node_modules folder by doing npm clean-install within your project directory
  4. Issue npm install to install all packages again
  5. Use: node -v to determine which version of node you have active. If the version outputted matches the version you set in the project your npm run build command will work. If they don't match you will either have to install the matching version of node or if you are using nvm use the: nvm use <version> to active the matching version.