Having trouble rebuilding main.js - Cannot find module 'browserify-swap'

I’ve installed (perhaps not properly?) npm and Node.js onto my Ubuntu 14.04 machine.
Here is the output in terminal, followed by the log file contents. If someone sees a glaring issue, I’d appreciate it. It seems to be looking for module ‘browserify-swap’ in my source web folder…

Here you see I try “npm run bundleDebug”:

bbiales@ubuntu:~/git/graphhopper/web$ npm run bundleDebug

> graphhopper-js-ui@1.0.0 bundleDebug /home/bbiales/git/graphhopper/web
> browserify src/main/webapp/js/main-template.js --debug -o src/main/webapp/js/main.js

Error: Cannot find module ‘browserify-swap’ from ‘/home/bbiales/git/graphhopper/web’
at /usr/lib/node_modules/browserify/node_modules/resolve/lib/async.js:46:17
at process (/usr/lib/node_modules/browserify/node_modules/resolve/lib/async.js:173:43)
at ondir (/usr/lib/node_modules/browserify/node_modules/resolve/lib/async.js:188:17)
at load (/usr/lib/node_modules/browserify/node_modules/resolve/lib/async.js:69:43)
at onex (/usr/lib/node_modules/browserify/node_modules/resolve/lib/async.js:92:31)
at /usr/lib/node_modules/browserify/node_modules/resolve/lib/async.js:22:47
at FSReqWrap.oncomplete (fs.js:111:15)

npm ERR! Linux 3.19.0-66-generic
npm ERR! argv “/usr/bin/nodejs” “/usr/bin/npm” “run” “bundleDebug”
npm ERR! node v7.0.0
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! graphhopper-js-ui@1.0.0 bundleDebug: browserify src/main/webapp/js/main-template.js --debug -o src/main/webapp/js/main.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the graphhopper-js-ui@1.0.0 bundleDebug script ‘browserify src/main/webapp/js/main-template.js --debug -o src/main/webapp/js/main.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 graphhopper-js-ui package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! browserify src/main/webapp/js/main-template.js --debug -o src/main/webapp/js/main.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs graphhopper-js-ui
npm ERR! Or if that isn’t available, you can get their info via:
npm ERR! npm owner ls graphhopper-js-ui
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! Please include the following file with any support request:
npm ERR! /home/bbiales/git/graphhopper/web/npm-debug.log

And here is the content from the npm-debug.log file referenced in the line above:

0 info it worked if it ends with ok
1 verbose cli [ ‘/usr/bin/nodejs’, ‘/usr/bin/npm’, ‘run’, ‘bundleDebug’ ]
2 info using npm@3.10.8
3 info using node@v7.0.0
4 verbose run-script [ ‘prebundleDebug’, ‘bundleDebug’, ‘postbundleDebug’ ]
5 info lifecycle graphhopper-js-ui@1.0.0~prebundleDebug: graphhopper-js-ui@1.0.0
6 silly lifecycle graphhopper-js-ui@1.0.0~prebundleDebug: no script for prebundleDebug, continuing
7 info lifecycle graphhopper-js-ui@1.0.0~bundleDebug: graphhopper-js-ui@1.0.0
8 verbose lifecycle graphhopper-js-ui@1.0.0~bundleDebug: unsafe-perm in lifecycle true
9 verbose lifecycle graphhopper-js-ui@1.0.0~bundleDebug: PATH: /usr/lib/node_modules/npm/bin/node-gyp-bin:/home/bbiales/git/graphhopper/web/node_modules/.bin:/home/bbiales/.local/share/umake/bin:/bin:/usr/bin:/opt/thinlinc/bin:/usr/local/bin:/usr/bin/X11:/sbin:/usr/sbin:/usr/local/sbin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin
10 verbose lifecycle graphhopper-js-ui@1.0.0~bundleDebug: CWD: /home/bbiales/git/graphhopper/web
11 silly lifecycle graphhopper-js-ui@1.0.0~bundleDebug: Args: [ ‘-c’,
11 silly lifecycle ‘browserify src/main/webapp/js/main-template.js --debug -o src/main/webapp/js/main.js’ ]
12 silly lifecycle graphhopper-js-ui@1.0.0~bundleDebug: Returned: code: 1 signal: null
13 info lifecycle graphhopper-js-ui@1.0.0~bundleDebug: Failed to exec bundleDebug script
14 verbose stack Error: graphhopper-js-ui@1.0.0 bundleDebug: browserify src/main/webapp/js/main-template.js --debug -o src/main/webapp/js/main.js
14 verbose stack Exit status 1
14 verbose stack at EventEmitter. (/usr/lib/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. (/usr/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 graphhopper-js-ui@1.0.0
16 verbose cwd /home/bbiales/git/graphhopper/web
17 error Linux 3.19.0-66-generic
18 error argv “/usr/bin/nodejs” “/usr/bin/npm” “run” “bundleDebug”
19 error node v7.0.0
20 error npm v3.10.8
21 error code ELIFECYCLE
22 error graphhopper-js-ui@1.0.0 bundleDebug: browserify src/main/webapp/js/main-template.js --debug -o src/main/webapp/js/main.js
22 error Exit status 1
23 error Failed at the graphhopper-js-ui@1.0.0 bundleDebug script ‘browserify src/main/webapp/js/main-template.js --debug -o src/main/webapp/js/main.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 graphhopper-js-ui package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error browserify src/main/webapp/js/main-template.js --debug -o src/main/webapp/js/main.js
23 error You can get information on how to open an issue for this project with:
23 error npm bugs graphhopper-js-ui
23 error Or if that isn’t available, you can get their info via:
23 error npm owner ls graphhopper-js-ui
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

Can you try to upgrade node and npm? Using npm 3.10.7 and node v6.4.0 should be something which works :slight_smile:

Hmmm. I have npm 3.10.8 and node 7.0.0. You recommend downgrading them then? I had installed node 6 (I’m assuming it was the “latest” version of 6) and that didn’t work, so I tried upgrading that.

I also had executed "sudo npm install -g browsifyer"
and the same for browsifier-swap.

Now I tried it without the -g scope, and now I get a different error: Cannot find module 'leaflet’
So I executed: "sudo npm install leaflet"
It gets further now. Says it cannot find module ‘d3’…
“sudo npm install d3”, then try to bundle:
Cannot find module ‘leaflet-loading’
… Did I miss a step? Why do I have to keep running these installs? Was there an automated step to do all these I missed?

Well, I continued installing one at a time as the bundle reported one was missing. I think there were about 3 or 4 more to go. Now I got all the dependencies, and it is working!

Normally a simple (sudo) npm install should be sufficient. Did you try this before as recommended in the docs? Maybe the docs are a bit hidden?

Dang! Well, if hidden, then the instructions were hidden in plain sight!
I skipped over these instructions:
cd graphhopper/web
# download required packages:
npm install
npm test
# overwrites main.js
npm run bundle

And went straight to the command to “npm run bundeDebug” because I want to be able to step through some of it.

My ignorance of how npm works and missing those steps caused some grief! I didn’t realize that “npm install” installs all the necessary dependencies.

Thanks again for the help.

1 Like