nodemon: Nodemon crashes with `Cannot read property 'map' of undefined`

  • nodemon -v: “^1.18.6”
  • node -v: v10.13.0
  • Operating system/terminal environment: ubunutu 18.04
  • Command you ran: npm start in package.json I have “start”: “nodemon”

Expected behaviour

It should run and rerun on changes

Actual behaviour

It errors each time I try to save my changes and gives this

/home/user/projects/mongodb-todo/node_modules/nodemon/lib/monitor/run.js:336 spawn(‘kill’, [‘-s’, sig, child.pid].concat(kids.map(p => p.PID))) ^

TypeError: Cannot read property ‘map’ of undefined at /home/user/projects/mongodb-todo/node_modules/nodemon/lib/monitor/run.js:336:58 at /home/user/projects/mongodb-todo/node_modules/pstree.remy/lib/tree.js:53:11 at ChildProcess.onClose (/home/user/projects/mongodb-todo/node_modules/pstree.remy/lib/tree.js:80:9) at ChildProcess.emit (events.js:182:13) at maybeClose (internal/child_process.js:962:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! mongodb-todo@1.0.0 start: nodemon npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the mongodb-todo@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/user/.npm/_logs/2018-11-22T12_10_04_952Z-debug.log

Steps to reproduce

install express, morgan, nodemon. run npm start then save changes in app.js

Here is package.json { “name”: “mongodb-todo”, “version”: “1.0.0”, “description”: “”, “main”: “./app.js”, “scripts”: { “test”: “echo "Error: no test specified" && exit 1”, “start”: “nodemon” }, “author”: “”, “license”: “ISC”, “dependencies”: { “express”: “^4.16.4”, “morgan”: “^1.9.1”, “nodemon”: “^1.18.6” } }


If applicable, please append the --dump flag on your command and include the output here ensuring to remove any sensitive/personal details or tokens.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 4
  • Comments: 23 (2 by maintainers)

Commits related to this issue

Most upvoted comments

nodemon dependencies pstree.remy check your package-lock.json
if use “pstree.remy”: “1.1.1”, will has this error use npm i pstree.remy@1.1.0 -D will fix this error I hope I can help you. :)

Only One Solutiion try this: “npm cache clean --force”

Try to use (npm install nodemon).

Fixed and deployed in latest release (going live right now)

I’m having a similar issue - different error message but nodemon is crashing upon attempting to restart. Node versions: v10.13.0 and v11.2.0 Nodemon version: 1.18.6 and 1.18.3

[nodemon] 1.18.6
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node first-app.js`
rs
/Users/ckunze/src/prof_dev/node-tutorial/node_modules/pstree.remy/lib/tree.js:70
  ps.stdout.on('data', function(data) {
            ^

TypeError: Cannot read property 'on' of undefined
    at buildProcessTree (/Users/ckunze/src/prof_dev/node-tutorial/node_modules/pstree.remy/lib/tree.js:70:13)
    at /Users/ckunze/src/prof_dev/node-tutorial/node_modules/pstree.remy/lib/tree.js:91:7
    at Array.forEach (<anonymous>)
    at ChildProcess.onClose (/Users/ckunze/src/prof_dev/node-tutorial/node_modules/pstree.remy/lib/tree.js:86:27)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:978:16)
    at Socket.stream.socket.on (internal/child_process.js:395:11)
    at Socket.emit (events.js:182:13)
    at Pipe._handle.close (net.js:616:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-tutorial@1.0.0 start: `nodemon first-app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-tutorial@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Is this related or should I start another issue?

Well, I deleted the folder and created everything and it workwd okay…

Guys, instead of posting new issues: Just read/search for already open/closed ones…