gpt4 book ai didi

javascript - browserify 'Error: Cannot find module' 试图修复 'Uncaught reference error: require is not defined'

转载 作者:行者123 更新时间:2023-11-30 17:22:00 26 4
gpt4 key购买 nike

关于 Uncaught ReferenceError ,我在这个线程(Node.js + Angular = Uncaught ReferenceError: require is not defined)中遇到了与@RachelD 非常相似或几乎完全相同的问题。但是,当我按照此处的说明 (https://github.com/substack/node-browserify) 运行我的“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)

如何克服这个错误?

最佳答案

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

关于javascript - browserify 'Error: Cannot find module' 试图修复 'Uncaught reference error: require is not defined',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24985962/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com