我试图在ubuntu(linux)机器中使用gulp构建来运行node.js项目。 当我尝试安装“ sudo npm install”时,它始终显示在错误下方:
> sharp@0.19.1 install /home/east/Documents/rht/PlateRate/BackUp/PlateRate_2686/node_modules/sharp
> node-gyp rebuild
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/east/Documents/rht/PlateRate/BackUp/PlateRate_2686/node_modules/sharp/build'
gyp ERR! System Linux 4.4.0-93-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/east/Documents/rht/PlateRate/BackUp/PlateRate_2686/node_modules/sharp
gyp ERR! node -v v8.11.2
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN PlateRate@1.3.4 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! sharp@0.19.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sharp@0.19.1 install 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/east/.npm/_logs/2018-07-26T06_56_51_290Z-debug.log
即使在此之后,当我尝试sudo gulp构建时,它再次显示以下错误:
[12:29:11] Using gulpfile ~/Documents/rht/PlateRate/BackUp/PlateRate_2686/gulpfile.js
[12:29:11] Starting 'build'...
[12:29:11] Starting 'styles'...
[12:29:11] 'styles' errored after 148 ms
[12:29:11] Error: ENOENT: no such file or directory, scandir '/home/east/Documents/rht/PlateRate/BackUp/PlateRate_2686/node_modules/node-sass/vendor'
at Object.fs.readdirSync (fs.js:904:18)
at Object.getInstalledBinaries (/home/east/Documents/rht/PlateRate/BackUp/PlateRate_2686/node_modules/node-sass/lib/extensions.js:129:13)
at foundBinariesList (/home/east/Documents/rht/PlateRate/BackUp/PlateRate_2686/node_modules/node-sass/lib/errors.js:20:15)
at foundBinaries (/home/east/Documents/rht/PlateRate/BackUp/PlateRate_2686/node_modules/node-sass/lib/errors.js:15:5)
at Object.module.exports.missingBinary (/home/east/Documents/rht/PlateRate/BackUp/PlateRate_2686/node_modules/node-sass/lib/errors.js:45:5)
at module.exports (/home/east/Documents/rht/PlateRate/BackUp/PlateRate_2686/node_modules/node-sass/lib/binding.js:15:30)
at Object.<anonymous> (/home/east/Documents/rht/PlateRate/BackUp/PlateRate_2686/node_modules/node-sass/lib/index.js:14:35)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
[12:29:11] 'build' errored after 151 ms
[12:29:11] Error in plugin 'run-sequence(styles)'
Message:
ENOENT: no such file or directory, scandir '/home/east/Documents/rht/PlateRate/BackUp/PlateRate_2686/node_modules/node-sass/vendor'
Details:
errno: -2
code: ENOENT
syscall: scandir
path: /home/east/Documents/rht/PlateRate/BackUp/PlateRate_2686/node_modules/node-sass/vendor
Stack:
Error: ENOENT: no such file or directory, scandir '/home/east/Documents/rht/PlateRate/BackUp/PlateRate_2686/node_modules/node-sass/vendor'
at Object.fs.readdirSync (fs.js:904:18)
at Object.getInstalledBinaries (/home/east/Documents/rht/PlateRate/BackUp/PlateRate_2686/node_modules/node-sass/lib/extensions.js:129:13)
at foundBinariesList (/home/east/Documents/rht/PlateRate/BackUp/PlateRate_2686/node_modules/node-sass/lib/errors.js:20:15)
at foundBinaries (/home/east/Documents/rht/PlateRate/BackUp/PlateRate_2686/node_modules/node-sass/lib/errors.js:15:5)
at Object.module.exports.missingBinary (/home/east/Documents/rht/PlateRate/BackUp/PlateRate_2686/node_modules/node-sass/lib/errors.js:45:5)
at module.exports (/home/east/Documents/rht/PlateRate/BackUp/PlateRate_2686/node_modules/node-sass/lib/binding.js:15:30)
at Object.<anonymous> (/home/east/Documents/rht/PlateRate/BackUp/PlateRate_2686/node_modules/node-sass/lib/index.js:14:35)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
请大家帮帮我。
谢谢
答案 0 :(得分:0)
之所以发生这种情况,是因为由于对npm的权限不足而无法创建目录'/home/east/Documents/rht/PlateRate/BackUp/PlateRate_2686/node_modules/sharp/build'
。
要解决此问题,请将npm的默认目录更改为主文件夹中的隐藏目录:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
source ~/.profile
希望这会起作用。