libsass bindings not found when using node-sass in

2019-01-10 01:17发布

I want to use the node-sass module in my node.js v0.12 application to benefit from the performance of libsass.
I executed npm i node-sass to install the module, no errors so far.

Now the mess starts:
If I just open the REPL in a terminal to try out node-sass then everything works fine but if I include it in my project files and run node myfile.js then I get the following error message:

Error: `libsass` bindings not found. Try reinstalling `node-sass`?

The module's description at npmjs.com states that there might be a problem with resolving #!/usr/bin/env node under Ubuntu and how to fix this but that is not the case on my machine.
I could not find anything useful so I hope that you might help me.

I'm using node v0.12.2 under Ubuntu 14.10.

P.S.: I already tried to reinstall node-sass but without success. Nothing changes.

12条回答
Explosion°爆炸
2楼-- · 2019-01-10 01:26

Combining the two answers above worked for me, plus additions:

sudo npm uninstall --save gulp-sass
npm install --save gulp-sass@2
npm update
npm rebuild node-sass
查看更多
ゆ 、 Hurt°
3楼-- · 2019-01-10 01:29
仙女界的扛把子
4楼-- · 2019-01-10 01:32

This workaround (http://forum.ionicframework.com/t/error-running-gulp-sass/32311/20) worked form me.

Starting with this setup:

Cordova CLI: 5.3.3 Gulp version: CLI version 3.9.0 Gulp local: Local version 3.9.0 Ionic Version: 1.1.0 Ionic CLI Version: 1.6.5 Ionic App Lib Version: 0.3.9 ios-deploy version: Not installed ios-sim version: 5.0.1 OS: Mac OS X Yosemite Node Version: v4.1.1 Xcode version: Xcode 6.4 Build version 6E35b

I've found a solution to avoid to use 'sudo' command. We need before to fix npm permissions following this: https://docs.npmjs.com/getting-started/fixing-npm-permissions and fixing permissions for Node here: http://mawaha.com/permission-fix-node-js/ After this we can check and reinstall software without 'sudo' for npm, n or ionic.

I followed this step:

npm install -g n
rm -R node_modules/ 
npm install node-sass@3.3.3 
npm -g install node-gyp@3
npm uninstall gulp-sass
npm install gulp-sass@2 
npm rebuild node-sass 
ionic setup sass 

Why node-sass@3.3.3? Because it works with latest ionic version: https://github.com/driftyco/ionic/pull/4449

查看更多
孤傲高冷的网名
5楼-- · 2019-01-10 01:33

I have solved this to create the right directory with the specified binding.node file. You can download the bindings from github

https://github.com/sass/node-sass-binaries

Look in the error message the path where it tries to find the binding. In my case:

C:\Users\Martijn\Documents\node_modules\gulp-sass\node_modules\node-sass\vendor\win32-x64-46

So I create this map win32-x64-46 and copy the binding from github in.

查看更多
走好不送
6楼-- · 2019-01-10 01:35

This was a Node version issue for me, try using nvm to backtrack your version to something like: 0.10.32. This worked for me. I was running 4.2.2

查看更多
Bombasti
7楼-- · 2019-01-10 01:37

If you're using node 4.x or later then you need to reinstall gulp-sass with:

npm uninstall --save-dev gulp-sass
npm install --save-dev gulp-sass@2
查看更多
登录 后发表回答