我正在尝试将node-sass安装为全局包。但是如果我在npm install node-sass之后尝试使用它,我只会得到错误:
找不到命令:node-sass
我还尝试过多次卸载和安装节点(通过网站和自制程序),但它没有改变任何东西。我也遵循了所有指示:https://docs.npmjs.com/getting-started/fixing-npm-permissions。我没有想法可以解决这个问题。如果我执行sudo npm install,我会收到以下错误消息:
node-sass@4.6.0 install /Users/s.brauns/node_modules/node-sass
node scripts/install.js
Unable to save binary /Users/s.brauns/node_modules/node-sass/vendor/darwin-x64-59 : { Error: EACCES: permission denied, mkdir '/Users/s.brauns/node_modules/node-sass/vendor'
at Object.fs.mkdirSync (fs.js:905:18)
at sync (/Users/s.brauns/node_modules/mkdirp/index.js:71:13)
at Function.sync (/Users/s.brauns/node_modules/mkdirp/index.js:77:24)
at checkAndDownloadBinary (/Users/s.brauns/node_modules/node-sass/scripts/install.js:111:11)
at Object.<anonymous> (/Users/s.brauns/node_modules/node-sass/scripts/install.js:154:1)
at Module._compile (module.js:641:30)
at Object.Module._extensions..js (module.js:652:10)
at Module.load (module.js:560:32)
at tryModuleLoad (module.js:503:12)
at Function.Module._load (module.js:495:3)
errno: -13,
code: 'EACCES',
syscall: 'mkdir',
path: '/Users/s.brauns/node_modules/node-sass/vendor' }
node-sass@4.6.0 postinstall /Users/s.brauns/node_modules/node-sass
node scripts/build.js
Building: /usr/local/bin/node /Users/s.brauns/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 '/Users/s.brauns/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.1.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` failed Error: not found: python2
gyp verb `which` failed at getNotFoundError (/Users/s.brauns/node_modules/which/which.js:13:12)
gyp verb `which` failed at F (/Users/s.brauns/node_modules/which/which.js:68:19)
gyp verb `which` failed at E (/Users/s.brauns/node_modules/which/which.js:80:29)
gyp verb `which` failed at /Users/s.brauns/node_modules/which/which.js:89:16
gyp verb `which` failed at /Users/s.brauns/node_modules/isexe/index.js:42:5
gyp verb `which` failed at /Users/s.brauns/node_modules/isexe/mode.js:8:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:166:21)
gyp verb `which` failed python2 { Error: not found: python2
gyp verb `which` failed at getNotFoundError (/Users/s.brauns/node_modules/which/which.js:13:12)
gyp verb `which` failed at F (/Users/s.brauns/node_modules/which/which.js:68:19)
gyp verb `which` failed at E (/Users/s.brauns/node_modules/which/which.js:80:29)
gyp verb `which` failed at /Users/s.brauns/node_modules/which/which.js:89:16
gyp verb `which` failed at /Users/s.brauns/node_modules/isexe/index.js:42:5
gyp verb `which` failed at /Users/s.brauns/node_modules/isexe/mode.js:8:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:166:21)
gyp verb `which` failed stack: 'Error: not found: python2\n at getNotFoundError (/Users/s.brauns/node_modules/which/which.js:13:12)\n at F (/Users/s.brauns/node_modules/which/which.js:68:19)\n at E (/Users/s.brauns/node_modules/which/which.js:80:29)\n at /Users/s.brauns/node_modules/which/which.js:89:16\n at /Users/s.brauns/node_modules/isexe/index.js:42:5\n at /Users/s.brauns/node_modules/isexe/mode.js:8:5\n at FSReqWrap.oncomplete (fs.js:166:21)',
gyp verb `which` failed code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python /usr/bin/python
gyp verb check python version `/usr/bin/python -c "import platform; print(platform.python_version());"` returned: "2.7.10\n"
gyp verb get node dir no --target version specified, falling back to host node version: 9.1.0
gyp verb command install [ '9.1.0' ]
gyp verb install input version string "9.1.0"
gyp verb install installing version: 9.1.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.1.0
gyp verb build dir attempting to create "build" dir: /Users/s.brauns/node_modules/node-sass/build
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/s.brauns/node_modules/node-sass/build'
gyp ERR! System Darwin 16.4.0
gyp ERR! command "/usr/local/bin/node" "/Users/s.brauns/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/s.brauns/node_modules/node-sass
gyp ERR! node -v v9.1.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1
npm WARN babel-loader@6.4.1 requires a peer of webpack@1 || 2 || ^2.1.0-beta || ^2.2.0-rc but none is installed. You must install peer dependencies yourself.
npm WARN extract-text-webpack-plugin@1.0.1 requires a peer of webpack@^1.9.11 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-dev-server@1.16.5 requires a peer of webpack@>=1.3.0 <3 but none is installed. You must install peer dependencies yourself.
npm WARN s.brauns@1.0.0 No description
npm WARN s.brauns@1.0.0 No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.6.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.6.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! /Users/s.brauns/.npm/_logs/2017-11-10T08_56_56_379Z-debug.log