我有问题构建一个应用程序,因为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 cache clean --force &&  
rm -rf node_modules &&  
rm -rf package-lock.json &&  
npm i

其他回答

删除“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.

如果你的终端/命令提示符显示:

Node Sass could not find a binding 
for your current environment: 
OS X 64-bit with Node 0.10.x

并且您已经尝试了以下命令,例如:

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

仍然没有工作…

只需在终端中手动运行:node node_modules/node-sass/scripts/install.js

现在运行NPM start或yarn start

我在本地运行Docker中的一个构建时,使用一个节点alpine映像,很长一段时间都有这个问题。我用下面的代码来创建基础层:

FROM node:19.4-alpine3.17 AS node_base
RUN apk update && \
    apk add python3 make && \
    rm -rf /var/cache/apk/*

它缺少了一个包:g++。把上面的改为下面的,对我来说很管用:

FROM node:19.4-alpine3.17 AS node_base
RUN apk update && \
    apk add python3 make g++ && \
    rm -rf /var/cache/apk/*

我相信这与带有M1芯片的macbook PRO的架构有关,在其他机器上我不会遇到这个错误,但我还没有测试过。

请在根文件夹上写下以下命令。

NPM重建node-sass

100%的作品……