我对此线程(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)
如何解决此错误?
答案 0 :(得分:2)
您使用的是绝对路径:/app/scripts/controllers/main.js
。您可能需要app/scripts/controllers/main.js
。