无法安装npm依赖项

时间:2017-12-16 16:54:36

标签: node.js sass npm-install node-sass

npm install

时出错
$ sudo rm -rf node_modules
[11:50:13] ➜  service-app rbenv:(2.4.2) git:(feature/order) ✗
$ sudo npm install


> fsevents@1.1.3 install /Users/alder/Projects/_apps/service_exchange/service-app/node_modules/fsevents
> node install

[fsevents] Success: "/Users/alder/Projects/_apps/service_exchange/service-app/node_modules/fsevents/lib/binding/Release/node-v59-darwin-x64/fse.node" is installed via remote

> node-sass@4.7.2 install /Users/alder/Projects/_apps/service_exchange/service-app/node_modules/node-sass
> node scripts/install.js

Unable to save binary /Users/alder/Projects/_apps/service_exchange/service-app/node_modules/node-sass/vendor/darwin-x64-59 : { Error: EACCES: permission denied, mkdir '/Users/alder/Projects/_apps/service_exchange/service-app/node_modules/node-sass/vendor'
    at Object.fs.mkdirSync (fs.js:905:18)
    at sync (/Users/alder/Projects/_apps/service_exchange/service-app/node_modules/mkdirp/index.js:71:13)
    at Function.sync (/Users/alder/Projects/_apps/service_exchange/service-app/node_modules/mkdirp/index.js:77:24)
    at checkAndDownloadBinary (/Users/alder/Projects/_apps/service_exchange/service-app/node_modules/node-sass/scripts/install.js:111:11)
    at Object.<anonymous> (/Users/alder/Projects/_apps/service_exchange/service-app/node_modules/node-sass/scripts/install.js:154:1)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
  errno: -13,
  code: 'EACCES',
  syscall: 'mkdir',
  path: '/Users/alder/Projects/_apps/service_exchange/service-app/node_modules/node-sass/vendor' }

> uglifyjs-webpack-plugin@0.4.6 postinstall /Users/alder/Projects/_apps/service_exchange/service-app/node_modules/webpack/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js


> node-sass@4.7.2 postinstall /Users/alder/Projects/_apps/service_exchange/service-app/node_modules/node-sass
> node scripts/build.js

Building: /usr/local/Cellar/node/9.3.0_1/bin/node /Users/alder/Projects/_apps/service_exchange/service-app/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/Cellar/node/9.3.0_1/bin/node',
gyp verb cli   '/Users/alder/Projects/_apps/service_exchange/service-app/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@9.3.0 | darwin | 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/local/bin/python2
gyp verb check python version `/usr/local/bin/python2 -c "import platform; print(platform.python_version());"` returned: "2.7.14\n"
gyp verb get node dir no --target version specified, falling back to host node version: 9.3.0
gyp verb command install [ '9.3.0' ]
gyp verb install input version string "9.3.0"
gyp verb install installing version: 9.3.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: 9.3.0
gyp verb build dir attempting to create "build" dir: /Users/alder/Projects/_apps/service_exchange/service-app/node_modules/node-sass/build
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/alder/Projects/_apps/service_exchange/service-app/node_modules/node-sass/build'
gyp ERR! System Darwin 17.2.0
gyp ERR! command "/usr/local/Cellar/node/9.3.0_1/bin/node" "/Users/alder/Projects/_apps/service_exchange/service-app/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/alder/Projects/_apps/service_exchange/service-app/node_modules/node-sass
gyp ERR! node -v v9.3.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.7.2 (node_modules/node-sass):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.7.2 postinstall: `node scripts/build.js`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

added 1336 packages in 36.348s

我完全重新安装了节点,但每次都是同样的事情。我试过fix permissions,但它也没有帮助。

$ node -v
v9.3.0
$ npm -v
5.6.0

$ node -p process.versions { http_parser: '2.7.0', node: '9.3.0', v8: '6.2.414.46-node.15', uv: '1.18.0', zlib: '1.2.11', ares: '1.13.0', modules: '59', nghttp2: '1.25.0', openssl: '1.0.2n', icu: '60.2', unicode: '10.0', cldr: '32.0.1', tz: '2017c' }

$ node -p process.platform darwin $ node -p process.arch x64

macOS High Sierra 10.13.1

1 个答案:

答案 0 :(得分:0)

帮助将npm路径更改为用户目录link