【问题标题】:Installing node-sass on ubuntu 18.04 returns error在 ubuntu 18.04 上安装 node-sass 返回错误
【发布时间】:2018-11-12 11:39:08
【问题描述】:

我正在尝试在 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 存在于主文件夹中,即使是那个供应商文件夹。你能帮帮我吗?

【问题讨论】:

    标签: node.js linux sass ubuntu-18.04


    【解决方案1】:

    这是适合我的解决方案

    sudo npm install --unsafe-perm node-sass
    

    更新:由于 node-sass 大部分已被弃用,而是使用 sass npm 模块(完美运行,没有任何问题)。你可以找到它HERE

    【讨论】:

      【解决方案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 版本更改为最新版本并重新安装

      【讨论】:

      • 我不知道为什么,但它不起作用。我不知道为什么它不起作用。我会尝试重新安装整个系统并删除所有内容并重试。
      • 但是 node_modules 在主文件夹中对吗??
      • 你的意思是 node_modules 是否在主文件夹中?
      • 你的节点和 npm 版本是多少?你用非虚拟机吗?
      • 我总共有两个 node_modules 文件夹。一个在 /usr/lib/ 中,第二个在 /home 中,正如您在我发布的那两张图片中看到的那样。
      猜你喜欢
      • 1970-01-01
      • 2018-09-16
      • 2020-04-17
      • 2020-08-26
      • 1970-01-01
      • 1970-01-01
      • 2021-12-01
      • 2019-04-03
      • 2019-10-20
      相关资源
      最近更新 更多