首页 > 解决方案 > npm start 停止工作,但 sudo npm start 仍然有效

问题描述

我在 linux 上运行 nodejs 服务器,它运行良好。但是,重新启动我的计算机后,运行npm start不再有效 - 尽管运行sudo npm start确实有效。

npm start运行nodemon app.js

发生了什么,我该如何解决?

终端输出:

$ npm start

> server@1.0.0 start /home/tirafesi/Documents/MyProject/server
> nodemon app.js

[nodemon] 1.18.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node app.js`
[nodemon] Internal watch failed: watch /home/tirafesi/Documents/MyProject/server ENOSPC
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! server@1.0.0 start: `nodemon app.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the server@1.0.0 start 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/tirafesi/.npm/_logs/2018-10-30T14_32_41_443Z-debug.log

日志文件:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using npm@6.4.1
3 info using node@v8.12.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle server@1.0.0~prestart: server@1.0.0
6 info lifecycle server@1.0.0~start: server@1.0.0
7 verbose lifecycle server@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle server@1.0.0~start: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/tirafesi/Documents/MyProject/server/node_modules/.bin:/opt/ros/melodic/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle server@1.0.0~start: CWD: /home/tirafesi/Documents/MyProject/server
10 silly lifecycle server@1.0.0~start: Args: [ '-c', 'nodemon app.js' ]
11 silly lifecycle server@1.0.0~start: Returned: code: 1  signal: null
12 info lifecycle server@1.0.0~start: Failed to exec start script
13 verbose stack Error: server@1.0.0 start: `nodemon app.js`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301: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> (/usr/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:915:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid server@1.0.0
15 verbose cwd /home/tirafesi/Documents/MyProject/server
16 verbose Linux 4.15.0-36-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start"
18 verbose node v8.12.0
19 verbose npm  v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error server@1.0.0 start: `nodemon app.js`
22 error Exit status 1
23 error Failed at the server@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 [ 1, true ]

包.json

{
  "name": "server",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "start": "nodemon app.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bcrypt": "^3.0.2",
    "eslint": "^5.7.0",
    "express": "^4.16.3",
    "node-rsa": "^1.0.1",
    "nodemon": "^1.18.4",
    "sqlite3": "^4.0.2",
    "uuid": "^3.3.2"
  }
}

编辑:按要求添加 package.json。

标签: node.jsnpm

解决方案


推荐阅读