简体   繁体   中英

Installing node-sass on ubuntu 18.04 returns error

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 ?

主目录

usr目录

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

Here is the solution which works for me

sudo npm install --unsafe-perm node-sass

Have a nice day all (Y).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM