NPM安装node-sass @无法成功

时间:2017-10-28 05:31:24

标签: angular npm node-sass

未能npm intall angular-cli ,我将其追溯到node-sass。 它无法单独安装它。

发生了什么事。谁知道该怎么办?

$ sudo npm install -g node-sass@^4.0.0
/usr/local/bin/node-sass -> /usr/local/lib/node_modules/node-sass/bin/node-sass

> node-sass@4.5.3 install /usr/local/lib/node_modules/node-sass
> node scripts/install.js

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

> node-sass@4.5.3 postinstall /usr/local/lib/node_modules/node-sass
> node scripts/build.js

Building: /usr/local/bin/node /usr/local/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/local/bin/node',
gyp verb cli   '/usr/local/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 node-gyp@3.6.2
gyp info using node@8.8.1 | 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.8.1
gyp verb command install [ '8.8.1' ]
gyp verb install input version string "8.8.1"
gyp verb install installing version: 8.8.1
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.8.1
gyp verb build dir attempting to create "build" dir: /usr/local/lib/node_modules/node-sass/build
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/node-sass/build'
gyp ERR! System Linux 4.8.0-36-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/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/local/lib/node_modules/node-sass
gyp ERR! node -v v8.8.1
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! node-sass@4.5.3 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-sass@4.5.3 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/npuser/.npm/_logs/2017-10-28T05_28_22_601Z-debug.log

2 个答案:

答案 0 :(得分:1)

安装node-sass时出现问题,似乎尚未解决。作为一种解决方法,您可以使用--unsafe-perm flag。

sudo npm install --unsafe-perm = true -g node-sass

以下是node-sass“interpolate

的引用

答案 1 :(得分:0)

当你安装某些东西并得到像

这样的错误时
errno: -13,
code: 'EACCES',

它意味着安装需要一些权限才能将文件夹或文件添加到另一个文件夹。

因此,请尝试授予安装权限,例如

sudo npm install node-sass