本文介绍了无法安装node-sass因此无法安装gulp-sass的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立一个可以使用sass编译器和gulp的环境,但是我的环境的一部分是通过安装gulp-sass来设置的,但是,我得到一个错误。经过一番研究,显然是因为我没有节点问题。当我尝试使用

  sudo npm install -g node-sass 
安装node-sass >



我得到以下错误,请注意,gulp sass的错误几乎相同。

  / usr / bin / node-sass  - > / usr / lib / node_modules / node-sass / bin / node-sass 

> [email protected] install / usr / lib / node_modules / node-sass
>节点脚本/ install.js

无法保存二进制文件/ usr / lib / node_modules / node-sass / vendor / linux-x64-57:{错误:EACCES:permission denied,mkdir'/ usr / lib / node_modules / node-sass / vendor'
在Object.fs.mkdirSync(fs.js:892:18)
同步(/ usr / lib / node_modules / node-sass / node_modules / mkdirp /index.js:71:13)
在Function.sync(/usr/lib/node_modules/node-sass/node_modules/mkdirp/index.js:77:24)
在checkAndDownloadBinary(/ usr /lib/node_modules/node-sass/scripts/install.js:111:11)
在Object。< anonymous> (/usr/lib/node_modules/node-sass/scripts/install.js:154:1)
在Module._compile(module.js:624:30)
在Object.Module._extensions。在module.load(module.js:545:32)上的
在tryModuleLoad(module.js:508:12)
上的
。 Module._load(module.js:500:3)
errno:-13,
code:'EACCES',
syscall:'mkdir',
path:'/ usr / lib / node_modules / node-sass / vendor'}

> [email protected] postinstall / usr / lib / node_modules / node-sass
>节点脚本/ build.js

构建:/ usr / bin / node /usr/lib/node_modules/node-sass/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext = --libsass_cflags = --libsass_ldflags = --libsass_library =
如果它以ok结尾,它就会工作
gyp动词cli ['/ usr / bin / node',
gyp动词cli'/usr/lib/node_modules/node-sass/node_modules/node-gyp/bin/node-gyp.js',
gyp动词cli'重建',
gyp动词cli' - -verbose',
gyp动词cli'--libsass_ext =',
gyp动词cli'--libsass_cflags =',
gyp动词cli'--libsass_ldflags =',
gyp动词cli'--libsass_library =']
gyp info使用[email protected]
gyp info使用[email protected] | linux | x64
gyp动词命令rebuild []
gyp动词命令clean []
gyp动词清除build目录
gyp动词命令configure []
gyp动词检查python检查Python可执行文件python2中的PATH
gyp动词`which`成功python2 / usr / bin / python2
gyp动词检查python版本`/ usr / bin / python2 -cimport platform; print(platform.python_version());`returned:2.7.12\\\

gyp verb get节点dir no - 指定的版本,回退到主节点版本:8.7.0
gyp动词命令install ['8.7.0']
gyp动词安装输入版本字符串8.7.0
gyp动词安装安装版本:8.7.0
gyp动词安装 - 保证如果已经安装了
gyp动词安装版本已经安装,需要检查installVersion
gyp动词得到installVersion9
gyp动词需要installVersion 9
gyp动词安装版本不错
gyp动词get节点dir目标节点版本inst alt:8.7.0
gyp动词构建dir试图创建builddir:/ usr / lib / node_modules / node-sass / build
gyp ERR!配置错误
gyp ERR!堆栈错误:EACCES:权限被拒绝,mkdir'/ usr / lib / node_modules / node-sass / build'
gyp ERR!系统Linux 4.4.0-97-generic
gyp ERR! /usr/bin/node_modules/node-sass/node_modules/node-gyp/bin/node-gyp.jsrebuild--verbose--libsass_ext = --libsass_cflags =--libsass_ldflags =--libsass_library =
gyp ERR! cwd / usr / lib / node_modules / node-sass
gyp ERR! node -v v8.7.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR!不行
编译失败,错误代码为:1
npm ERR!代码ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall:`node scripts / build.js`
npm ERR!退出状态1
npm ERR!
npm ERR!在[email protected] postinstall脚本失败。
npm ERR!这可能不是npm的问题。上面可能还有其他日志记录输出。

npm ERR!此运行的完整日志可在以下位置找到:
npm ERR! /home/username/.npm/_logs/2017-10-21T00_11_47_487Z-debug.log

从什么我可以收集,问题可能要么与libsass或节点本身有关,但我不知道要采取哪些步骤。



如果有任何建议或指针任何人都可以给我,我会很高兴地感激它。



非常感谢!

解决方案

这可能是因为您安装 npm 时存在权限问题:


  • 介绍一般疑难解答这些问题与 npm 。首先完成这些步骤。

  • 描述了解决完全相同问题的人。

I'm trying to set up an environment in which I could use a sass compiler with gulp, part of my environment is set up by installing gulp-sass, however, I get an error. After some research, it is apparently because I do not have node-sass. When I try installing node-sass using

sudo npm install -g node-sass

I get the following error, please note that the error for gulp sass is pretty much identical.

/usr/bin/node-sass -> /usr/lib/node_modules/node-sass/bin/node-sass

> [email protected] install /usr/lib/node_modules/node-sass
> node scripts/install.js

Unable to save binary /usr/lib/node_modules/node-sass/vendor/linux-x64-57 : { Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/node-sass/vendor'
    at Object.fs.mkdirSync (fs.js:892:18)
    at sync (/usr/lib/node_modules/node-sass/node_modules/mkdirp/index.js:71:13)
    at Function.sync (/usr/lib/node_modules/node-sass/node_modules/mkdirp/index.js:77:24)
    at checkAndDownloadBinary (/usr/lib/node_modules/node-sass/scripts/install.js:111:11)
    at Object.<anonymous> (/usr/lib/node_modules/node-sass/scripts/install.js:154:1)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
  errno: -13,
  code: 'EACCES',
  syscall: 'mkdir',
  path: '/usr/lib/node_modules/node-sass/vendor' }

> [email protected] postinstall /usr/lib/node_modules/node-sass
> node scripts/build.js

Building: /usr/bin/node /usr/lib/node_modules/node-sass/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ '/usr/bin/node',
gyp verb cli   '/usr/lib/node_modules/node-sass/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library=' ]
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` succeeded python2 /usr/bin/python2
gyp verb check python version `/usr/bin/python2 -c "import platform; print(platform.python_version());"` returned: "2.7.12\n"
gyp verb get node dir no --target version specified, falling back to host node version: 8.7.0
gyp verb command install [ '8.7.0' ]
gyp verb install input version string "8.7.0"
gyp verb install installing version: 8.7.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 8.7.0
gyp verb build dir attempting to create "build" dir: /usr/lib/node_modules/node-sass/build
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/node-sass/build'
gyp ERR! System Linux 4.4.0-97-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/node-sass/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /usr/lib/node_modules/node-sass
gyp ERR! node -v v8.7.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/username/.npm/_logs/2017-10-21T00_11_47_487Z-debug.log

From what I can gather, the problem might either have to do with libsass or node itself but I am at a loss for which steps to follow.

If there are any advice or pointers anyone could give me, I would gladly appreciate it.

Thank you very much!

解决方案

This is likely because there are permissions problems with your installation of npm:

  • This page discusses general troubleshooting of these problems with npm. Complete these steps first.

  • This GitHub issue describes someone fixing the exact same issue.

这篇关于无法安装node-sass因此无法安装gulp-sass的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 19:08