当我在Linux服务器上执行npm启动时,我遇到了一个问题。
显示错误,退出代码为126,权限被拒绝。
我已经对server.js或更确切地说是demoTest的整个文件夹做了chmod 777
。
我该如何解决?
日志如下所示。
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 npm@5.6.0
3 info using node@v8.11.3
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle demoTest@1.0.0~prestart: demoTest@1.0.0
6 info lifecycle demoTest@1.0.0~start: demoTest@1.0.0
7 verbose lifecycle demoTest@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle demoTest@1.0.0~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 demoTest@1.0.0~start: CWD: /home/useradmin/demoTest
10 silly lifecycle demoTest@1.0.0~start: Args: [ '-c', 'nodemon ./rest/server.js' ]
11 silly lifecycle demoTest@1.0.0~start: Returned: code: 126 signal: null
12 info lifecycle demoTest@1.0.0~start: Failed to exec start script
13 verbose stack Error: demoTest@1.0.0 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 demoTest@1.0.0
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 demoTest@1.0.0 start: `nodemon ./rest/server.js`
22 error Exit status 126
23 error Failed at the demoTest@1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 126, true ]
答案 0 :(得分:0)
我正在使用nodemon,而intellij则抱怨“ app / server.js:权限被拒绝,错误号126”,直到我在package.json中的配置中添加了以下内容。
"scripts": {
"start": "nodemon app/server.js"
}
答案 1 :(得分:0)
在运行Nodejs服务器和Reactjs客户端时遇到了同样的问题。这个过程对我有用,应该在受影响的目录中完成(我认为这是demoTest
):
npm install
将依赖关系重新安装到该目录的package.json
我相信,当我将node_modules从主机复制到Ubuntu服务器而不是直接从服务器CLI运行安装程序时,就会出现此问题。