Npm error when starting 'node index.js' in section 15.8

I’m on section 15.8, “Adding an npm script.” Everything is working fine until I get to the end when the book tells me to type “npm run dev” into the terminal. When I try it I get an error, events.js:160. Here is the output from the log file:

0 info it worked if it ends with ok
1 verbose cli [ ‘C:\Program Files\nodejs\node.exe’,
1 verbose cli ‘C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js’,
1 verbose cli ‘run’,
1 verbose cli ‘dev’ ]
2 info using npm@3.10.10
3 info using node@v6.9.4
4 verbose run-script [ ‘predev’, ‘dev’, ‘postdev’ ]
5 info lifecycle chattrbox@1.0.0~predev: chattrbox@1.0.0
6 silly lifecycle chattrbox@1.0.0~predev: no script for predev, continuing
7 info lifecycle chattrbox@1.0.0~dev: chattrbox@1.0.0
8 verbose lifecycle chattrbox@1.0.0~dev: unsafe-perm in lifecycle true
9 verbose lifecycle chattrbox@1.0.0~dev: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;c:\Users\Steve\front-end-dev-book\chattrbox\node_modules.bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\Oracle\Java\javapath;C:\MinGW\bin;C:\Program Files (x86)\CMake\bin;C:\Windows\system32\config\systemprofile.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit;C:\Program Files\nodejs;C:\Program Files (x86)\Skype\Phone;C:\Program Files (x86)\SSH Secure Shell;C:\Users\Steve\AppData\Roaming\npm;C:\Users\Steve\AppData\Local\atom\bin
10 verbose lifecycle chattrbox@1.0.0~dev: CWD: c:\Users\Steve\front-end-dev-book\chattrbox
11 silly lifecycle chattrbox@1.0.0~dev: Args: [ ‘/d /s /c’, ‘nodemon index.js’ ]
12 silly lifecycle chattrbox@1.0.0~dev: Returned: code: 1 signal: null
13 info lifecycle chattrbox@1.0.0~dev: Failed to exec dev script
14 verbose stack Error: chattrbox@1.0.0 dev: nodemon index.js
14 verbose stack Exit status 1
14 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:255:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:877:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid chattrbox@1.0.0
16 verbose cwd c:\Users\Steve\front-end-dev-book\chattrbox
17 error Windows_NT 6.1.7601
18 error argv “C:\Program Files\nodejs\node.exe” “C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js” “run” "dev"
19 error node v6.9.4
20 error npm v3.10.10
21 error code ELIFECYCLE
22 error chattrbox@1.0.0 dev: nodemon index.js
22 error Exit status 1
23 error Failed at the chattrbox@1.0.0 dev script ‘nodemon index.js’.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the chattrbox package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error nodemon index.js
23 error You can get information on how to open an issue for this project with:
23 error npm bugs chattrbox
23 error Or if that isn’t available, you can get their info via:
23 error npm owner ls chattrbox
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

Hello Steve!

Two questions:

  • Do you get the same error if you just do node index.js?
  • And, what happens if you do nodemon index.js?

If you get the same error with nodemon index.js but not node index.js, make sure nodemon is installed by doing a npm install --save-dev nodemon

Let me know what happens.