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

末鹿安然 提交于 2020-01-05 04:05:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!