Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodemon crashes with Cannot read property 'map' of undefined #1459

Closed
t-zander opened this issue Nov 22, 2018 · 23 comments
Closed

Nodemon crashes with Cannot read property 'map' of undefined #1459

t-zander opened this issue Nov 22, 2018 · 23 comments
Labels
bug confirmed bug help wanted

Comments

@t-zander
Copy link

  • 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.

@lourenco
Copy link

Node 11 same issue :(

@sysrun
Copy link

sysrun commented Nov 22, 2018

#1456

@Evilu
Copy link

Evilu commented Nov 22, 2018

same here with macOS 10.13.6
node 10.13

@sysrun
Copy link

sysrun commented Nov 22, 2018

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

@cooliean
Copy link

cooliean commented Nov 23, 2018

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. :)

@remy remy changed the title Nodemon crushes every time I save changes Nodemon crashes with Cannot read property 'map' of undefined Nov 23, 2018
@remy
Copy link
Owner

remy commented Nov 23, 2018

Acknowledging this.

I've been trying to work on a fix, but work life and personal life has been keeping me away from coding on this.

The issue is in https://github.com/remy/pstree - and although I fixed the core of this issue, there's a new issue that leaves processes running in the background instead of killing them (which is exactly what pstree intends to address).

The tests pass fine in a mac environment (my dev machine), but not in linux - which travis runs in. I am able to replicate with docker (this branch: https://github.com/remy/nodemon/tree/fix/new-pstree ) but I don't know what's leaving the process in the background (it's definitely that pstree.remy isn't returning all the PIDs properly).

@remy remy added bug confirmed bug help wanted labels Nov 23, 2018
@t-zander
Copy link
Author

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

@Arti3DPlayer
Copy link

the same issue, pstree.remy@1.1.2

@corinnekunze
Copy link

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?

@actraiser
Copy link

I am able to replicate with docker (this branch: https://github.com/remy/nodemon/tree/fix/new-pstree ) but I don't know what's leaving the process in the background (it's definitely that pstree.remy isn't returning all the PIDs properly).

Experiencing the same problem that nodemon will report EADDRINUSE when reloading a watched file when run in a linux environment via Docker. In my case, I use the latest node-alpine v10.13.0 image.

-act

@jordie23
Copy link

@remy Can you please lock the nodemon dependency on pstree back to 1.1.0 ? Until you can release a 1.1.3 that fixes these issues?

@remy
Copy link
Owner

remy commented Nov 27, 2018

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

@remy remy closed this as completed Nov 27, 2018
@oliverbot
Copy link

oliverbot bot commented Nov 27, 2018

Thanks for raising this issue, and hopefully you're happy with @remy's fix. If you'd like to support this project, you can do just that through the open collective https://opencollective.com/nodemon/donate or at the very least, starring this project would give me @remy a little smile ❤️

bot-linagora pushed a commit to linagora/linshare-editor-onlyoffice that referenced this issue Dec 11, 2018
A fix to avoid 'crashes with 'Cannot read property 'map' of undefined'

remy/nodemon#1459
@ajay2323
Copy link

Only One Solutiion try this: "npm cache clean --force"

@pretti24
Copy link

Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1280:14)
at listenInCluster (net.js:1328:12)
at Server.listen (net.js:1415:7)
at Function.listen (/home/priti/Desktop/Calculator/node_modules/express/lib/application.js:618:24)
at Object. (/home/priti/Desktop/Calculator/calculator.js:9:5)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Emitted 'error' event at:
at emitErrorNT (net.js:1307:8)
at process._tickCallback (internal/process/next_tick.js:63:19)
at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
[nodemon] app crashed - waiting for file changes before starting...

@pretti24
Copy link

How to fix this??

@ajay2323
Copy link

How to fix this??

Try this "npm cache clean --force"

@pouriamoosavi
Copy link

I know it seems silly but I think it could be a problem with maximum number of watched files in OS. I faced the same problem and tried all above solutions, none works for me. but then I understand sometimes (in some runs) nodemon complains about maximum file watch. so I ignored some directories and now it does not have that problem anymore.

@Fengxusunny
Copy link

Try to use (npm install nodemon).

@ghost
Copy link

ghost commented Sep 7, 2020

internal/modules/cjs/loader.js:968
throw err;
^

Error: Cannot find module 'C:\Users\omnamashivaya\OneDrive\Desktop\Wiki_API\index.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

@ghost
Copy link

ghost commented Sep 7, 2020

how fix this

@ghost
Copy link

ghost commented Sep 7, 2020

pls I need help

@goyal-Dushi
Copy link

goyal-Dushi commented Dec 17, 2020

npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib'
npm ERR! { [Error: EACCES: permission denied, access '/usr/local/lib']
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, access '/usr/local/lib'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/dushyant/.npm/_logs/2020-12-17T12_10_14_491Z-debug.log

CMD : sudo npm install -g nodemon

After using the above command, it worked just fine.

Repository owner locked as resolved and limited conversation to collaborators Dec 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug confirmed bug help wanted
Projects
None yet
Development

No branches or pull requests