我有问题构建一个应用程序,因为node-sass不断失败的错误。

binding /Users/warren/Sites/random-docs/my-cms/node_modules/node-sass/vendor/darwin-x64-11/binding.node出错 Node Sass无法找到当前环境的绑定:OS X 64位的Node 0.10.x

我试过跑步

npm rebuild node-sass

二进制很好;退出。

当运行node -v时,我得到v6.2.2

这与sass错误说的“Node 0.10.x”不同。我不明白为什么它会得到错误的版本。我也尝试删除node_modules文件夹并运行npm update或npm install,这两者都没有解决问题。什么好主意吗?


当前回答

这招对我很管用: 纱线添加—force node-sass@4.14.1或纱线添加—force node-sass

其他回答

node-sass runs an install script to download the required binary. If there are no environment variables, .npmrc variables or process arguments set then the binary is determined by using the current process platform, architecture and Node ABI version. Therefore, if you run node install in one application and then try to run node-sass in an application with a different platform/architecture/ABI, the binary won't have been downloaded. The solution is to manually download the binary or to fix the binary version using an environment variable (SASS_BINARY_NAME) or a .npmrc variable (sass_binary_name)

你可以在node-sass\lib\extensions.js中的getBinaryPath函数中看到这个逻辑

在我的例子中,我在package-lock中发现了node-sass版本。Json与package.json中的node-sass版本不同。这一步解决了我的问题。

删除文件夹node-modules 删除package-lock.json 安装python 2.7 将C:/Python27;C:/Python27/Scripts添加到环境变量->路径 在Powershell中,以管理员身份执行-> npm install -g node-gyp 在我的工作文件夹-> NPM安装

希望这也适用于你

Mac:

- cmd + SHIFT + G ——/ usr /地方/ lib / node-sass -右击并重命名:应该仍然是相同的node-sass -然后执行NPM install node-sass -g

固定。

没有一个安装/重建解决方案为我解决了这个问题(使用gulp)。

我是这样解决的:

1)从存储库下载丢失的绑定文件。

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

3)如果不存在node_modules/node-sass/vendor/darwin-x64-11(错误信息中的路径)目录。

4)将绑定文件添加到“node_modules/node-sass/vendor/darwin-x64-11”目录下

在“node_modules/node-sass/vendor/linux-x64-46/”目录下新建一个目录。 从https://github.com/sass/node-sass/releases下载文件 (linux-x64-59_binding.node)。 将其粘贴到node_modules/node-sass/vendor/linux-x64-46/重命名为binding.node