多个 Node 版本缺少 Node Sass 绑定

3
我使用nvm来切换不同的Node版本。我的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" } ```
当我使用Node v6.2.0 并且运行 `npm run dev` 时,会出现以下错误:
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

当我使用 Node v7.8.0 时,会出现以下错误:

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

无论我使用哪个节点版本,它都会说缺少相应的绑定。
我尝试了多次运行`npm rebuild node-sass` 和 `rm -rf node_modules`。
甚至尝试了运行`npm install --save-dev gulp-sass@2`如此建议 here.
最初,我使用`brew`安装了node。那是v6.2.0. 我完全删除了`system`节点,如此建议here,然后使用nvm安装了相同的节点。
但问题仍然存在。请告诉我我在这里错过了什么。

你尝试过 npm rebuild node-sass --force 吗? - robertklep
1
刚刚尝试了一下,没有成功。 - Nihar
我可以重现这个问题,但是那解决了它。 - robertklep
4个回答

3
经过数小时的构建系统斗争,我放弃了。类似上面Matt所说的,我只是从https://github.com/sass/node-sass/releases下载了二进制文件。
(Matt的链接没有更新到Node 9)
我创建了一个目录,在其中运行webapp(在我的情况下是Webstorm)指定了缺失二进制文件的位置,下载了二进制文件。我将darwin-x64-59_binding.node重命名为binding.node然后尝试再次运行--这时它就可以工作了。

1

npm rebuild node-sass 对于 VS 2017 有效,但对于 VS Code 无效。在 VS Code 中运行前,我必须先运行 npm cache clean。我没有尝试过 npm rebuild node-sass --force,因为在找到这个页面之前我已经解决了问题,所以我不知道它是否会产生相同的效果。


0

我曾经遇到过与node-sass类似的问题,最终我从这里的github上获取了所需的二进制文件。

对于我来说,我需要win32-ia32-48,因此我创建了该文件夹,并从上面的链接中复制了binding.node文件(在重命名以删除win32-ia32-48前缀后)。


0

没有安装/重建的解决方案可以解决我的问题(使用gulp)。

以下是我解决的方法:

1)从repository下载缺失的绑定文件。

2)将文件重命名为binding.node

3)创建目录/node-modules/vendor/darwin-x64-51/

4)将binding.node文件添加到/node-modules/vendor/darwin-x64-51/中。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接