Node Sass missing binding for multiple node versio

2019-05-21 04:33发布

问题:

I am using nvm to switch between node versions.

My package.json:

"scripts": { "dev": "rm -rf public/assets/*.hot-update.js && NODE_ENV=development webpack --env=dev --progress --profile --colors", "prod": "NODE_ENV=production webpack --env=prod --progress --profile --colors" }, "author": "", "license": "ISC", "devDependencies": { "babel-core": "^6.18.2", "babel-loader": "^6.2.10", "babel-preset-es2015": "^6.18.0", "babel-preset-stage-0": "^6.16.0", "babel-preset-stage-2": "^6.18.0", "compression-webpack-plugin": "^0.3.2", "css-loader": "^0.26.2", "extract-text-webpack-plugin": "^2.0.0", "file-loader": "v0.10.0", "imports-loader": "^0.7.0", "node-sass": "^4.1.1", "postcss-cssnext": "^2.9.0", "sass-loader": "^4.1.1", "script-loader": "^0.7.0", "style-loader": "^0.13.1", "uglifyjs-webpack-plugin": "^0.1.2", "vue": "^2.0.3", "vue-lazyload": "0.7.5", "vue-loader": "^10.2.1", "vue-resource": "^1.2.0", "vue-style-loader": "^1.0.0", "vue-template-compiler": "^2.1.8", "vuex": "^2.0.0", "webpack": "2.2.0", "webpack-manifest-plugin": "^1.1.0", "webpack-md5-hash": "^0.0.5", "webpack-merge": "^2.6.1", "whatwg-fetch": "^2.0.2" }

When I am using Node v6.2.0, and run npm run dev, I get the following error:

ERROR in ./~/css-loader?{"minimize":true}!./~/vue-loader/lib/style-rewriter.js?id=data-v-be2abeee!./~/sass-loader!./~/vue-loader/lib/selector.js?type=styles&index=0!./~/@zoomcarindia/web-zap-revenue-calculator/src/components/graph/graph.vue
    Module build failed: Error: Missing binding /Users/nihar/Documents/zoomcar/web/node_modules/node-sass/vendor/darwin-x64-48/binding.node
    Node Sass could not find a binding for your current environment: OS X 64-bit with Node.js 6.x

Found bindings for the following environments:
  - OS X 64-bit with Node.js 7.x

and when I use Node v7.8.0, I get the following error:

ERROR in ./checklist/~/css-loader?{"minimize":true}!./~/vue-loader/lib/style-rewriter.js?id=data-v-a5234466!./checklist/~/sass-loader!./~/vue-loader/lib/selector.js?type=styles&index=0!./checklist/src/components/Upload.vue
    Module build failed: Error: Missing binding /Users/nihar/Documents/zoomcar/web/checklist/node_modules/node-sass/vendor/darwin-x64-51/binding.node
    Node Sass could not find a binding for your current environment: OS X 64-bit with Node.js 7.x

    Found bindings for the following environments:
      - Unknown environment (.DS_Store)
      - OS X 64-bit with Node.js 6.x

Whichever node version I use, it says the corresponding binding is missing.

I have tried npm rebuild node-sass and rm -rf node_modules multiple times.

Even tried npm install --save-dev gulp-sass@2 as suggested here.

Initially I had installed node using brew. That was v6.2.0. I removed the system node completely as suggested here, and then installed the same using nvm.

But the issue still persists. Please let me know what I am missing here.

回答1:

npm rebuild node-sass worked for VS 2017 but not for VS Code. I had to run npm cache clean before it would work in VS Code. I didn't try npm rebuild node-sass --force because I solved it before I found this page, so I don't know if that would have had the same effect or not.



回答2:

After hours of fighting build systems, I gave up and similar to Matt above, I just grabbed the binary from https://github.com/sass/node-sass/releases

(Matt's link did not go up to Node 9)

I created the directory where the run webapp (in my case Webstorm) said it was looking for the missing binary, downloaded the binary and in my case renamed darwin-x64-59_binding.node to binding.node and tried running again -- it then worked.



回答3:

So I had a similar issue with node-sass and just ended up grabbing the binaries I needed from github here.

For me I needed win32-ia32-48 and so I created that folder and copied in the binding.node file from the link above (after renaming it to remove the win32-ia32-48 prefix).



回答4:

None of the install/rebuild solutions resolved the issue for me (using gulp).

Here is how I resolved it:

1) Download the missing binding file from the repository.

2) Rename the file binding.node.

3) Create directory /node-modules/vendor/darwin-x64-51/

4) Add binding.node file to /node-modules/vendor/darwin-x64-51/