Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node-sass error (try reinstalling)

I'm trying to build a front-end server and when I run grunt I get this error with a suggestion to reinstall 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`?

The weird thing is that the file (binding.node) does exist, but it is in a folder named 'linux-x64-v8-3.14' not, 3.28. I tried naming the folder 3.14 that didn't work. I've tried everything I can thing of to get this fixed, npm install node-sass, npm update, even cleaning out the project and running npm install on a fresh build. But to no avail. I repeatedly get this error.

Has anyone seen this or know how to fix this? I am running Ubuntu 14.04 x64

Thanks!

like image 510
Shmuel Avatar asked Dec 24 '22 19:12

Shmuel


2 Answers

I ran into basically the same error on Debian Linux with gulp-sass(basically same thing as grunt-sass but for gulp... both are just wrappers for the respective tool around node-sass which is a nodejs port of the actual SASS compiler libsass).

The node-sass project mentions in their README.md that only binaries for "popular platforms"(apparently Windows/Mac) are included and you may need to build for other platforms.

I was able to resolve the issue by explicitly re-running the install and build scripts for node-sass directly on the Debian machine. Here are roughly the steps:

  • From a command prompt on your linux machine, cd to your project directory
  • cd to the node-sass directory within your project source. Probably something like cd node_modules/grunt-sass/node_modules/node-sass based on your original post
  • node scripts/install.js
  • node scripts/build.js
  • Should see a message like Binary is fine; exiting.. This will have added the correct node-sass binary for the platform the scripts were run on.
  • Try to run your grunt build again and hopefully it should work!
like image 57
munsellj Avatar answered Dec 27 '22 09:12

munsellj


I just ran npm install to install the project dependencies. Is there >something else I should run?(I'm new to web development. I'm a java/android >developer)

I do not thinks so. A basic set up, a project folder:

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

Gruntfile.js contains:

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']);
}

then run:

npm install grunt-sass

Now you should be able to run:

grunt

the above outputs now:

Running "sass:dist" (sass) task

Done, without errors.

Notice that the npm install grunt-sass commands should output something like that shown below, possible related to your error:

/
> [email protected] 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

> [email protected] 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.
like image 21
Bass Jobsen Avatar answered Dec 27 '22 07:12

Bass Jobsen