Не в состоянии запустить npm в задании crontab - PullRequest
0 голосов
/ 18 декабря 2018

Когда я запускаю npm, запускаю test123 из командной строки, он отлично работает:

root@ip-10-0-1-128:/app/babyBids# npm run test123

> baby@1.0.0 test123 /app/babyBids
> node -v

v10.13.0

Но если я запускаю его с помощью задания crontab, выдается ошибка:

Failed at the baby@1.0.0 test123 script.

Кто-нибудь может взглянуть?Спасибо.

Пользователь root

Система Ubuntu 16

crontab -e:

PATH=$PATH:/usr/games:/usr/local/games:/opt/node-v10.13.0-linux-x64/bin:/root/.local/bin
NODE_ENV=production
*/1 * * * * cd /app/babyBids && npm run test123

package.json:

"scripts": {
  "test123": "node -v"
}

cat /root/.npm/_logs/2018-12-17T22_34_01_468Z-debug.log

1 verbose cli [ '/opt/node-v10.13.0-linux-x64/bin/node',
1 verbose cli   '/opt/node-v10.13.0-linux-x64/bin/npm',
1 verbose cli   'run',
1 verbose cli   'test123' ]
2 info using npm@6.4.1
3 info using node@v10.13.0
4 verbose run-script [ 'pretest123', 'test123', 'posttest123' ]
5 info lifecycle baby@1.0.0~pretest123: baby@1.0.0
6 info lifecycle baby@1.0.0~test123: baby@1.0.0
7 verbose lifecycle baby@1.0.0~test123: unsafe-perm in lifecycle true
8 verbose lifecycle baby@1.0.0~test123: PATH: /opt/node-v10.13.0-linux-x64/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/app/babyBids/node_modules/.bin:$PATH:/usr/games:/usr/local/games:/opt/node-v10.13.0-linux-x64/bin:/root/.local/bin
9 verbose lifecycle baby@1.0.0~test123: CWD: /app/babyBids
10 silly lifecycle baby@1.0.0~test123: Args: [ '-c', 'node -v' ]
11 info lifecycle baby@1.0.0~test123: Failed to exec test123 script
12 silly lifecycle baby@1.0.0~test123: Returned: code: -2  signal: null
13 info lifecycle baby@1.0.0~test123: Failed to exec test123 script
14 verbose stack Error: baby@1.0.0 test123: `node -v`
14 verbose stack spawn sh ENOENT
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:232:19)
14 verbose stack     at onErrorNT (internal/child_process.js:407:16)
14 verbose stack     at process._tickCallback (internal/process/next_tick.js:63:19)
15 verbose pkgid baby@1.0.0
16 verbose cwd /app/babyBids
17 verbose Linux 4.15.0-1029-aws
18 verbose argv "/opt/node-v10.13.0-linux-x64/bin/node" "/opt/node-v10.13.0-linux-x64/bin/npm" "run" "test123"
19 verbose node v10.13.0
20 verbose npm  v6.4.1
21 error file sh
22 error path sh
23 error code ELIFECYCLE
24 error errno ENOENT
25 error syscall spawn sh
26 error baby@1.0.0 test123: `node -v`
26 error spawn sh ENOENT
27 error Failed at the baby@1.0.0 test123 script.
27 error This is probably not a problem with npm. There is likely additional logging output above.
28 verbose exit [ 1, true ]
...