4

我正在尝试构建一个前端服务器,当我运行 grunt 时,我收到此错误,并建议重新安装 node-sass。

Aborted due to warnings.
dev@ubuntu:~/ideaProjects/web-app$ grunt app:dashboard/dev-dashboard --force
Loading "sass.js" tasks...ERROR
Error: `/home/dev/ideaProjects/web-app/node_modules/grunt-sass/node_modules/node-sass/bin/linux-x64-v8-3.28/binding.node` is missing. 
Try reinstalling `node-sass`?

奇怪的是文件(binding.node)确实存在,但它位于名为“linux-x64-v8-3.14”的文件夹中,而不是 3.28。我尝试将文件夹命名为 3.14 不起作用。我已经尽我所能来修复这个问题,npm install node-sass,npm update,甚至清理项目并在新版本上运行 npm install。但无济于事。我反复收到此错误。

有没有人看到这个或知道如何解决这个问题?我正在运行 Ubuntu 14.04 x64

谢谢!

4

2 回答 2

6

我在使用 gulp-sass 的 Debian Linux 上遇到了基本相同的错误(与 grunt-sass 基本相同,但对于 gulp ......两者都只是围绕node-sass的相应工具的包装器,它是实际 SASS 编译器的 nodejs 端口库萨斯)。

node-sass项目在其 README.md 中提到,包含“流行平台”(显然是 Windows/Mac)的二进制文件,您可能需要为其他平台构建。

我能够通过直接在 Debian 机器上显式地重新运行 node-sass 的安装和构建脚本来解决这个问题。大致步骤如下:

  • 从你的 linux 机器上的命令提示符,cd 到你的项目目录
  • cd 到项目源中的 node-sass 目录。可能类似于cd node_modules/grunt-sass/node_modules/node-sass基于您的原始帖子
  • node scripts/install.js
  • node scripts/build.js
  • 应该看到类似的消息Binary is fine; exiting.。这将为运行脚本的平台添加正确的 node-sass 二进制文件。
  • 尝试再次运行您的 grunt 构建,希望它应该可以工作!
于 2015-07-10T23:47:28.300 回答
4

我刚刚运行 npm install 来安装项目依赖项。还有其他我应该运行的东西吗?(我是 web 开发的新手。我是 java/android >开发人员)

我不这么认为。一个基本设置,一个项目文件夹:

.
├── Gruntfile.js
├── node_modules
└── sass
    └── main.scss

Gruntfile.js 包含:

module.exports = function (grunt) {

grunt.loadNpmTasks('grunt-sass');

grunt.initConfig({
    sass: {
        options: {
            sourceMap: true
        },
        dist: {
            files: {
                'css/main.css': 'sass/main.scss'
            }
        }
    }
});

grunt.registerTask('default', ['sass']);
}

然后运行:

npm install grunt-sass

现在您应该能够运行:

grunt

现在上面的输出:

Running "sass:dist" (sass) task

Done, without errors.

请注意,npm install grunt-sass命令应输出如下所示的内容,可能与您的错误有关:

/
> node-sass@3.1.2 install /home/testdrive/sassgrunt/node_modules/grunt-sass/node_modules/node-sass
> node scripts/install.js

Binary downloaded and installed at /home/testdrive/sassgrunt/node_modules/grunt-sass/node_modules/node-sass/vendor/linux-x64-14/binding.node

> node-sass@3.1.2 postinstall /home/testdrive/sassgrunt/node_modules/grunt-sass/node_modules/node-sass
> node scripts/build.js

` /home/testdrive/sassgrunt/node_modules/grunt-sass/node_modules/node-sass/vendor/linux-x64-14/binding.node ` exists. 
 testing binary.
Binary is fine; exiting.
于 2015-05-22T16:31:12.000 回答