browserify'错误:无法找到模块'试图修复'未捕获的引用错误:需要未定义'

时间:2014-07-27 21:45:24

标签: javascript node.js angularjs express browserify

我对此线程(Node.js + Angular = Uncaught ReferenceError: require is not defined)中有关Uncaught引用错误的@RachelD问题非常类似或几乎完全相同。但是,当我运行我的浏览器时,这里的指示所指示的命令(https://github.com/substack/node-browserify),如下所示(我也包括我的目录以供参考)......

myname@compname:~/workspace/MyApp $ browserify /app/scripts/controllers/main.js > bundle.js

我正在找到一个“找不到模块”'错误

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)

如何解决此错误?

1 个答案:

答案 0 :(得分:2)

您使用的是绝对路径:/app/scripts/controllers/main.js。您可能需要app/scripts/controllers/main.js