我有问题构建一个应用程序,因为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,这两者都没有解决问题。什么好主意吗?


当前回答

NPM重建node-sass——force

或者,如果你在容器中使用node-sass:

Docker exec <container-id> NPM rebuild node-sass——force

当node-sass没有当前操作系统的正确绑定时,会发生此错误。

如果你使用Docker,当你将node_modules直接添加到Dockerfile中的容器文件系统(或使用Docker卷挂载它们)时,通常会发生这种错误。

容器体系结构可能与当前的操作系统不同。例如,我在macOS上安装node-sass,但我的容器运行Ubuntu。

如果强制node-sass从容器内部重新构建,node-sass将下载容器操作系统的正确绑定。

查看我的复制案例了解更多。

其他回答

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

我是这样解决的:

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

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

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

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

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

在linux ubuntu 20.04上,我需要几个步骤,首先将节点降级到合适的版本,删除node_modules,运行yarn install,最后运行sudo yarn add node-sass@4.13.0——force。节点版本号10.0.0。 这是我唯一的工作方式。

删除“node_modules”文件夹。 重新安装依赖项。(npm)

Windows 10 This was a fun one for me... In order to resolve it I had to do all of the following.. 1.) Apparently node-sass isn't supported by some of the more recent versions of Node.js so I had to Uninstall Node-v 12.14.1, and delete the nodejs directory in C:/Program Files. 2.) Reinstall a earlier version of Node (for me 10.16.2 worked). NOTE: I had initially downloaded the x86 version so if your System is x64 download the x64 verison... 3.) From here I had to delete my entire project and re-clone it. After this things ran fine.