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


当前回答

如果你在mac上安装Xcode。

其他回答

Docker相关的答案在这里*

回答如果你看到这个问题,或类似的东西,并正在使用Docker。

原因:当将当前文件结构复制到Docker容器内部时,你可能会将节点模块从一个OS系统复制到另一个OS系统(例如,从Mac到Linux容器)。

解决方案:

添加一个.dockerignore,然后在里面添加:

node_modules

这将导致npm install为docker环境而不是本地机器环境安装绑定。


**只需执行:** 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

对我来说,是maven-war-plugin对文件应用了过滤器,损坏了woff文件。

<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
    <webResources>
        <resource>
            <directory>dist</directory>
            <filtering>true</filtering>
        </resource>
    </webResources>
</configuration>

真正删除<过滤> < /过滤>

或者如果你需要过滤,你可以这样做:

<plugin>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
        <webResources>
            <resource>
                <directory>dist</directory>
                <excludes>
                    <exclude>assets/**/*</exclude>
                </excludes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>dist</directory>
                <includes>
                    <include>assets/**/*</include>
                </includes>
            </resource>
        </webResources>
    </configuration>
</plugin>

在删除node_modules或清理缓存(这会花费时间)之前,尝试运行

NPM重建node-sass——force

在项目文件夹中。就像我的一样,你的问题得到解决的几率很高。如果不成功,试试下面的方法:

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

npm start

如果你在mac上安装Xcode。