即使nvm在6.9.0上,node-sass也会下载4.x版的二进制文件

时间:2017-03-16 13:10:40

标签: node.js npm ubuntu-16.04 nvm node-sass

我尝试从节点4.4.5迁移到6.9.0(npm 3.10.8)。我删除了node_modules目录,执行了nvm install 6.9.0并执行了npm install。这很好。但是当我尝试使用gulp构建我的项目时,它会给我以下错误

Error: Missing binding /home/ubuntu/web/node_modules/node-sass/vendor/linux-x64-48/binding.node

Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 6.x

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

This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to build the binding for your current environment.
at module.exports (/home/ubuntu/web/node_modules/node-sass/lib/binding.js:15:13)
at Object.<anonymous> (/home/ubuntu/web/node_modules/node-sass/lib/index.js:14:35)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/ubuntu/web/node_modules/gulp-sass/index.js:187:21)

然后我做了npm rebuild node-sass。这没有下载任何新的二进制文件。

> node-sass@3.13.1 install /home/ubuntu/web/node_modules/node-sass 
> node scripts/install.js

node-sass build Binary found at /home/ubuntu/web/node_modules/node-sass/vendor/linux-x64-46/binding.node

> node-sass@3.13.1 postinstall /home/ubuntu/web/node_modules/node-sass
> node scripts/build.js

Binary found at /home/ubuntu/web/node_modules/node-sass/vendor/linux-x64-46/binding.node
Testing binary
Binary is fine

我再次尝试构建,但最终又出现了第一个错误。请帮忙。

2 个答案:

答案 0 :(得分:1)

如果您删除方向 node_module 并再次执行npm install但它  仍然没有工作,我认为这可能是你的网络问题。如果你在中国我认为以下内容可能会有所帮助: 找到你安装的node.js文件 .npmrc ,并通过添加来修改它 sass_binary_site=https://npm.taobao.org/mirrors/node-sass/然后运行npm install然后就可以了。

答案 1 :(得分:0)

我遇到了类似的问题,我通过删除所有npm模块并重新构建来解决这个问题:

rm -Rf ./node_modules
npm prune
npm rebuild node-sass
npm install