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


当前回答

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.

其他回答


**只需执行:** npm rebuild node-sass——force



If the above for some reason didn't work out for you, try this:

删除“node_modules”下的“node-sass”文件夹 npm安装


在我的例子中,它也找不到Python。

以下步骤解决了该问题(Windows):

npm rebuild node-sass --force
-- cannot find python.exe, if you have Python installed, add it to your path:
set PYTHON=C:\Python27\Python.exe
-- else: download python "Windows x86-64-MSI" installer from https://www.python.org/downloads/release/python-2714/
-- install python
-- at installation start check: add env variable to path
-- after successfull installation:
npm rebuild node-sass --force
-- finished successfully

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

node-sass节点模块使用依赖于节点版本的达尔文二进制文件。没有下载二进制文件或下载了错误的二进制文件时,会出现此问题。

[![节点sass错误][1]][1].

重新安装节点模块将下载node-sass的二进制文件:-

Mac用户:

rm -rf node_modules
npm cache clean --force
npm i
npm rebuild node-sass --force

Windows用户:

rmdir node_modules
npm cache clean --force
npm i
npm rebuild node-sass --force

但是对于某些用户,您需要检查您的节点版本与node-sass版本的兼容性。使用下面的表使其兼容,并再次运行以上命令来修复此问题。

这是node-sass的节点兼容性表

NodeJS | Supported node-sass version | Node Module
Node 17     7.0+                        102
Node 16     6.0+                        93
Node 15     5.0+                        88
Node 14     4.14+                       83
Node 13     4.13+, <5.0                 79
Node 12     4.12+                       72
Node 11     4.10+, <5.0                 67
Node 10     4.9+, <6.0                  64
Node 8      4.5.3+, <5.0                57
Node <8     <5.0                        <57

如果问题仍未解决,请检查node-sass支持的环境列表:—https://github.com/sass/node-sass/releases/

在“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

我通过将JAVA_HOME从x86更改为x64来解决这个问题。Maven在x86上运行,但node使用x64。删除/node和/node_modules并重新构建。