问题
I am having a very similar, or almost exact, issue to @RachelD from this thread (Node.js + Angular = Uncaught ReferenceError: require is not defined) regarding the Uncaught reference error. However, when I run my 'browserify' command as stated in the directions here (https://github.com/substack/node-browserify) and exactly as shown below (I included my directory as well for reference)...
myname@compname:~/workspace/MyApp $ browserify /app/scripts/controllers/main.js > bundle.js
I am getting a 'Cannot find module' error
Error: Cannot find module '/app/scripts/controllers/main.js' from '/Users/myname/workspace/MyApp'
at /usr/local/lib/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:35:25
at load (/usr/local/lib/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:53:43)
at /usr/local/lib/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:59:22
at /usr/local/lib/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:16:47
at Object.oncomplete (fs.js:107:15)
How do I get past this error?
回答1:
You are using an absolute path: /app/scripts/controllers/main.js
. You probably want app/scripts/controllers/main.js
.
来源:https://stackoverflow.com/questions/24985962/browserify-error-cannot-find-module-in-trying-to-fix-uncaught-reference-erro