【问题标题】:browserify exclude cannot find modulebrowserify exclude 找不到模块
【发布时间】:2015-01-15 01:09:04
【问题描述】:

我正在尝试让一个节点模块在浏览器中工作,但我不希望 browserify 包含内联 require,因为我正在单独加载它。

问题是,即使我正在加载带有<script> 标签的超级代理,browserify 也会抛出异常:Uncaught Error: Cannot find module superagent'

外壳

browserify --x superagent source.js -o output.js

script(src='/bower/superagent/superagent.js')
script(src='/js/output.js')

souce.js

var superagent = require('superagent');
module.exports = { }

如何在不引发异常的情况下从浏览器中排除 require()?

【问题讨论】:

    标签: javascript node.js browserify


    【解决方案1】:

    我想通了……

    browserify -i superagent --standalone iceberg source.js > output.js

    然后在浏览器中只引用独立参数:

    <script>
     iceberg.lettuce.eat();
    </script>
    

    http://www.forbeslindesay.co.uk/post/46324645400/standalone-browserify-builds

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多