gpt4 book ai didi

node.js - npm 错误!将 bash 脚本与 npm 一起使用时的代码 ELIFECYCLE

转载 作者:太空宇宙 更新时间:2023-11-03 23:01:18 25 4
gpt4 key购买 nike

我只是想使用一些 bash 来检查一些事情,然后运行我想要的命令。但我遇到了第一个障碍:

hutber.sh

#!/bin/bash
echo 'hutber' ; exit 1;

package.json

"hutber": "./hutber.sh"

终端

hutber@hutber-mint /var/www/mvt-framework $ npm run hutber

> mvt-framework@0.0.1 hutber /var/www/mvt-framework
> ./hutber.sh

hutber
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mvt-framework@0.0.1 hutber: `./hutber.sh`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mvt-framework@0.0.1 hutber 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/hutber/.npm/_logs/2017-12-05T15_52_44_355Z-debug.log

错误日志

0 info it worked if it ends with ok
1 verbose cli [ '/home/hutber/.nvm/versions/node/v8.7.0/bin/node',
1 verbose cli '/home/hutber/.nvm/versions/node/v8.7.0/bin/npm',
1 verbose cli 'run',
1 verbose cli 'hutber' ]
2 info using npm@5.4.2
3 info using node@v8.7.0
4 verbose run-script [ 'prehutber', 'hutber', 'posthutber' ]
5 info lifecycle mvt-framework@0.0.1~prehutber: mvt-framework@0.0.1
6 info lifecycle mvt-framework@0.0.1~hutber: mvt-framework@0.0.1
7 verbose lifecycle mvt-framework@0.0.1~hutber: unsafe-perm in lifecycle true
8 verbose lifecycle mvt-framework@0.0.1~hutber: PATH: /home/hutber/.nvm/versions/node/v8.7.0/lib/node_modules/npm/bin/node-gyp-bin:/var/www/mvt-framework/node_modules/.bin:/home/hutber/.nvm/versions/node/v8.7.0/bin:/home/hutber/bin:/home/hutber/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/hutber/Android/Sdk/tools:/home/hutber/Android/Sdk/platform-tools
9 verbose lifecycle mvt-framework@0.0.1~hutber: CWD: /var/www/mvt-framework
10 silly lifecycle mvt-framework@0.0.1~hutber: Args: [ '-c', './hutber.sh' ]
11 silly lifecycle mvt-framework@0.0.1~hutber: Returned: code: 1 signal: null
12 info lifecycle mvt-framework@0.0.1~hutber: Failed to exec hutber script
13 verbose stack Error: mvt-framework@0.0.1 hutber: `./hutber.sh`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/home/hutber/.nvm/versions/node/v8.7.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:280:16)
13 verbose stack at emitTwo (events.js:125:13)
13 verbose stack at EventEmitter.emit (events.js:213:7)
13 verbose stack at ChildProcess.<anonymous> (/home/hutber/.nvm/versions/node/v8.7.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at emitTwo (events.js:125:13)
13 verbose stack at ChildProcess.emit (events.js:213:7)
13 verbose stack at maybeClose (internal/child_process.js:927:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
14 verbose pkgid mvt-framework@0.0.1
15 verbose cwd /var/www/mvt-framework
16 verbose Linux 4.4.0-53-generic
17 verbose argv "/home/hutber/.nvm/versions/node/v8.7.0/bin/node" "/home/hutber/.nvm/versions/node/v8.7.0/bin/npm" "run" "hutber"
18 verbose node v8.7.0
19 verbose npm v5.4.2
20 error code ELIFECYCLE
21 error errno 1
22 error mvt-framework@0.0.1 hutber: `./hutber.sh`
22 error Exit status 1
23 error Failed at the mvt-framework@0.0.1 hutber script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

最佳答案

它按预期工作。
您以代码错误 1 ​​结束 bash 脚本,用于捕获一般错误,因此 npm 会抛出错误。

error code ELIFECYCLE
error errno 1

如果你更改为代码 0,它将毫无错误地结束:

#!/bin/bash
echo 'hutber' ; exit 0;

关于node.js - npm 错误!将 bash 脚本与 npm 一起使用时的代码 ELIFECYCLE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47657718/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com