Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing node-sass on ubuntu 18.04 returns error

Tags:

I'm trying to install node-sass on ubuntu, beacuse I want to use sass-autocompile, but even when I try to compile that sass file in atom (just when I save it) It returns this error:

`fs.js:904
   return binding.readdir(pathModule._makeLong(path), options.encoding) 

 Error: ENOENT: no such file or directory, scandir 
   '/usr/lib/node_modules/node-sass/vendor'
   at Object.fs.readdirSync (fs.js:904:18)
   at Object.getInstalledBinaries (/usr/lib/node_modules/node- 
     sass/lib/extensions.js:129:13)
   at foundBinariesList (/usr/lib/node_modules/node- 
     sass/lib/errors.js:20:15)
   at foundBinaries (/usr/lib/node_modules/node-sass/lib/errors.js:15:5)
   at Object.module.exports.missingBinary (/usr/lib/node_modules/node- 
     sass/lib/errors.js:45:5)
   at module.exports (/usr/lib/node_modules/node-sass/lib/binding.js:15:30)
   at Object.<anonymous> (/usr/lib/node_modules/node- 
      sass/lib/index.js:14:35)
   at Module._compile (module.js:652:30)
   at Object.Module._extensions..js (module.js:663:10)
   at Module.load (module.js:565:32)`

I tried to use this command npm rebuild node-sass and it didn't fix the problem, even with --force

And removing nodejs and node-sass and npm and installing again didn't fix the problem and yes I do have ruby installed.

But one thing is really strange: this path node_modules/node-sass/vendor' exists in home folder, basically node_modules exists in home folder even with that vendor folder. Can you help me out ?

Home directory

usr directory

like image 903
SenTisso Avatar asked Jun 02 '18 15:06

SenTisso


2 Answers

Here is the solution which works for me

sudo npm install --unsafe-perm node-sass

Update: Since node-sass is mostly deprecated use instead sass npm module(works perfect whithout any issues).You can find it HERE.

like image 65
Goran_Ilic_Ilke Avatar answered Sep 28 '22 17:09

Goran_Ilic_Ilke


so after reading some of the workarounds on https://github.com/sass/node-sass/issues/1579 here is my suggestion

first remove node_modules directory and re-install dependencies npm install if its still not working then

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

npm rebuild node-sass

if it's still not working, change your node-sass version to the latest and re-install it again

like image 40
ShegaMike Avatar answered Sep 28 '22 17:09

ShegaMike