简体   繁体   中英

browserify 'Error: Cannot find module' in trying to fix 'Uncaught reference error: require is not defined'

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?

You are using an absolute path: /app/scripts/controllers/main.js . You probably want app/scripts/controllers/main.js .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM