安装node-sass时出现问题

时间:2018-06-01 14:27:25

标签: node.js node-sass

安装node-sass时遇到问题:

gyp verb download contents checksum {"node-v10.2.1-headers.tar.gz":"3700814861e61288d7dd1c4115f40acac0cbd0abbdd4bfd650d4ae85cc02ecce"}
gyp verb validating download checksum for node-v10.2.1-headers.tar.gz (3700814861e61288d7dd1c4115f40acac0cbd0abbdd4bfd650d4ae85cc02ecce == 3700814861e61288d7dd1c4115f40acac0cbd0abbdd4bfd650d4ae85cc02ecce)
gyp verb get node dir target node version installed: 10.2.1
gyp verb build dir attempting to create "build" dir: /var/www/****/node_modules/node-sass/build
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/var/www/****/node_modules/node-sass/build'
gyp ERR! System Linux 4.4.0-116-generic
gyp ERR! command "/usr/local/bin/node" "/var/www/****/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /var/www/****/node_modules/node-sass
gyp ERR! node -v v10.2.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1
npm WARN gestiaweb@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.9.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.9.0 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/****/.npm/_logs/2018-06-01T14_24_13_534Z-debug.log

环境: Ubuntu(最新)

NodeJS版本: v10.2.1

Npm版本: 5.6.0

2 个答案:

答案 0 :(得分:0)

gyp ERR! stack Error: EACCES: permission denied, 

它的说法被拒绝了。尝试使用sudo运行

sudo npm i node-sass

答案 1 :(得分:0)

看起来存在权限问题。你能安装其他套餐吗?

如果没有确保运行npm i node-gyp命令的用户有权写入相应的目录。

chmod +w <path>/node_modules

在这种情况下,用户的节点安装似乎存在权限问题

解决方案:

sudo su && npm i node-sass