Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build nodejs Fail with exit status 126 - Permission denied

Tags:

linux

node.js

I faced a issue when I do a npm start in my linux server.

It is showing error with exit code 126 and permission denied.

I have already done chmod 777 to server.js or rather to the whole folder of demoTest.

How do I fixed this?

The log is shown as below.

info it worked if it ends with ok
1 verbose cli [ '/opt/node-v8.11.3-linux-x64/bin/node', '/bin/npm', 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]~prestart: [email protected]
6 info lifecycle [email protected]~start: [email protected]
7 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~start: PATH: /opt/node-v8.11.3-linux-x64/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/useradmin/demoTest/node_modules/.bin:/sbin:/bin:/usr/sbin:/usr/bin
9 verbose lifecycle [email protected]~start: CWD: /home/useradmin/demoTest
10 silly lifecycle [email protected]~start: Args: [ '-c', 'nodemon ./rest/server.js' ]
11 silly lifecycle [email protected]~start: Returned: code: 126  signal: null
12 info lifecycle [email protected]~start: Failed to exec start script
13 verbose stack Error: [email protected] start: `nodemon ./rest/server.js`
13 verbose stack Exit status 126
13 verbose stack     at EventEmitter.<anonymous> (/opt/node-v8.11.3-linux-x64/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (/opt/node-v8.11.3-linux-x64/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:925:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid [email protected]
15 verbose cwd /home/useradmin/demoTest/rest
16 verbose Linux 3.10.0-862.el7.x86_64
17 verbose argv "/opt/node-v8.11.3-linux-x64/bin/node" "/bin/npm" "start"
18 verbose node v8.11.3
19 verbose npm  v5.6.0
20 error code ELIFECYCLE
21 error errno 126
22 error [email protected] start: `nodemon ./rest/server.js`
22 error Exit status 126
23 error Failed at the [email protected] start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 126, true ]
like image 430
shadow Avatar asked Sep 20 '18 00:09

shadow


1 Answers

I was getting this same issue when running a Nodejs server and Reactjs client. This process worked for me and should be done in the affected directory (I think that's demoTest for you):

  1. Delete node_modules
  2. Run npm install to reinstall the dependencies in that directory's package.json

I believe this problem started when I copied node_modules from my host to my Ubuntu server rather than running the installs directly from the server CLI.

like image 136
Chimera.Zen Avatar answered Nov 07 '22 09:11

Chimera.Zen