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


当前回答

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函数中看到这个逻辑

其他回答

对我来说,是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文件夹并重新安装,或者在删除后运行gradle任务deploy

/用户/沃伦/网站/ random-docs / my-cms / node_modules node-sass /供应商/ darwin-x64-11 / binding.node

它解决了你的问题。

我在从VS 2017专业版升级到企业版时遇到了这个问题

密切与 删除node_modules 开放和 右键单击包。Json,然后选择“restore packages”

如果没有包,node-sass的post依赖项将无法安装。node-sass中的Json

手动运行它为我解决了问题

node node_modules/node-sass/scripts/install.js 

信贷:链接

如果你读到这篇文章的结尾,但仍然没有工作。这可能有点傻,但试着验证一下你的文件夹中是否有以下文件:

.node-version .nvmrc

他们是事情不适合你的罪魁祸首。用节点版本更新文件,然后重新运行此线程中其他人提供的过程。它会起作用的。;)