【问题标题】:how to run node.js project with gulp build如何使用 gulp build 运行 node.js 项目
【发布时间】:2018-07-26 07:00:36
【问题描述】:

我试图在 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 build 时,它再次显示以下错误:

[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)

请大家帮帮我。

谢谢,

【问题讨论】:

    标签: node.js gulp gulp-sass


    【解决方案1】:

    发生这种情况是因为对 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

    希望这会奏效。

    【讨论】:

      猜你喜欢
      • 2018-03-11
      • 2017-01-14
      • 1970-01-01
      • 2017-10-22
      • 2020-05-01
      • 1970-01-01
      • 2020-12-23
      • 2012-07-08
      • 2018-05-23
      相关资源
      最近更新 更多