LRK9 LRK9 - 3 months ago 62
Node.js Question

NodeJS Cannot find module

My co-worker told me to checkout a Git repo that he's been working on.

The app uses NodeJS. I did "git clone" and then "npm install". My co-worker told me to then run "npm start". I tried this and I got an error. We decided the problem was my old version of Node. He was running with version 4 and I was way back on 0.6.

So I upgraded. I am on a Mac. I uninstalled Node using Homebrew, then re-installed Node using Homebrew.

Now:

node -v
v6.5.0


So now I do "npm install" and then "npm start". Now I get a different error:

npm start

> api-reference@0.0.1 start /Users/lLRK9/projects/zeria/api
> node server.js

module.js:457
throw err;
^

Error: Cannot find module './config/manifest.json'
at Function.Module._resolveFilename (module.js:455:15)
at Function.Module._load (module.js:403:25)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/lLRK9/projects/zeria/api/server.js:5:18)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)

npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/Cellar/node/6.5.0/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.5.0
npm ERR! npm v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! api-reference@0.0.1 start: `node server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the api-reference@0.0.1 start script 'node server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the api-reference package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs api-reference
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls api-reference
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/lLRK9/projects/zeria/api/npm-debug.log



cat /Users/lLRK9/projects/zeria/api/npm-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/6.5.0/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'start' ]
2 info using npm@3.10.3
3 info using node@v6.5.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle api-reference@0.0.1~prestart: api-reference@0.0.1
6 silly lifecycle api-reference@0.0.1~prestart: no script for prestart, continuing
7 info lifecycle api-reference@0.0.1~start: api-reference@0.0.1
8 verbose lifecycle api-reference@0.0.1~start: unsafe-perm in lifecycle true
9 verbose lifecycle api-reference@0.0.1~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/lLRK9/projects/zeria/api/node_modules/.bin:/usr/local/Cellar/node/6.5.0/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/Cellar/node/6.5.0/bin/node:/usr/local/bin/brew:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/mysql/bin
10 verbose lifecycle api-reference@0.0.1~start: CWD: /Users/lLRK9/projects/zeria/api
11 silly lifecycle api-reference@0.0.1~start: Args: [ '-c', 'node server.js' ]
12 silly lifecycle api-reference@0.0.1~start: Returned: code: 1 signal: null
13 info lifecycle api-reference@0.0.1~start: Failed to exec start script
14 verbose stack Error: api-reference@0.0.1 start: `node server.js`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:242: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.<anonymous> (/usr/local/lib/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 api-reference@0.0.1
16 verbose cwd /Users/lLRK9/projects/zeria/api
17 error Darwin 15.6.0
18 error argv "/usr/local/Cellar/node/6.5.0/bin/node" "/usr/local/bin/npm" "start"
19 error node v6.5.0
20 error npm v3.10.3
21 error code ELIFECYCLE
22 error api-reference@0.0.1 start: `node server.js`
22 error Exit status 1
23 error Failed at the api-reference@0.0.1 start script 'node server.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 api-reference package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error node server.js
23 error You can get information on how to open an issue for this project with:
23 error npm bugs api-reference
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls api-reference
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]


This app works for my co-worker. What differences in our setups might allow this app to work for him, but not for me?

Answer

Error: Cannot find module './config/manifest.json'

This looks like some local config file you're missing. You should ask him for it.

Alternatively, if there is an install hook in the package.json of the module, it may be attempting to configure this manifest.json file automatically, and it's possible that install script failed. You should check if there is any custom install hook as well.

(Also, I'd recommend using n in the future for managing Node.js versions).