在Ubuntu 18.04上安装node-sass返回错误

5
我正在尝试在Ubuntu上安装node-sass,因为我想使用sass-autocompile,但即使我尝试在Atom中编译那个Sass文件(只是当我保存它时),它也会返回以下错误:
`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)`

我尝试使用这个命令 npm rebuild node-sass,但是即使加上了 --force,问题依然没有解决。

卸载并重新安装 nodejs、node-sass 和 npm 也无法解决问题,而且我的电脑上已经安装了 Ruby。

但有一件事情真的很奇怪:这个路径 node_modules/node-sass/vendor' 存在于主目录中,基本上 node_modules 存在于主目录中,甚至带有那个 vendor 文件夹。你能帮我解决这个问题吗?

Home directory

usr directory

2个回答

3
这是适用于我的解决方案。
sudo npm install --unsafe-perm node-sass

更新:由于node-sass大部分已被弃用,因此请使用sass npm模块(完全没有任何问题就能正常工作)。您可以在这里找到它。


2

在阅读了一些关于https://github.com/sass/node-sass/issues/1579的解决方法之后,这是我的建议:

首先删除node_modules目录并重新安装依赖项npm install如果仍然无法正常工作,则

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

npm rebuild node-sass

如果仍然无法正常工作,请将您的 node-sass 版本更改为最新版本,然后再次重新安装它。

我不知道为什么,但它没有起作用。我不知道为什么它不起作用。我将尝试重新安装整个系统并删除所有内容,然后再次尝试。 - SenTisso
但是 node_modules 在主文件夹里面是正确的吗? - SenTisso
“你的意思是 node_modules 在 home 文件夹里面对吗?” - miqe
你的 Node 和 NPM 版本是什么?你使用 nvm 吗? - miqe
我总共有两个node_modules文件夹。一个在/usr/lib/中,另一个在/home中,正如我发布的这两张图片所示。 - SenTisso

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接