如何使browserify
在编译时显示错误行和文件:
browserify -t coffeeify mainPage_browserify.coffee > main.js -d
当前输出不提供此信息。因此很难调试:
⏎
Error: Cannot find module 'throw' from '/allProjectsPath/project/public/javascripts/map'
at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:50:17
at process (/usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:119:43)
at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:128:21
at load (/usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:60:43)
at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:66:22
at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:21:47
at Object.oncomplete (fs.js:107:15)
❯ browserify --version ⏎
5.12.1
答案 0 :(得分:1)
我自己对此感兴趣,所以我快速浏览了源代码并运行调试器。看起来使用命令行browserify时,基本上会吞下来自转换的错误。
来自coffeeify的错误是使用流上的事件发射器传递的......
https://github.com/substack/coffeeify/blob/master/index.js#L35
仅当bundle
调用回调存在时才由Browserify处理......
https://github.com/substack/node-browserify/blob/master/index.js#L619
不幸的是,在运行命令行时没有传递回调...
https://github.com/substack/node-browserify/blob/master/bin/cmd.js#L55