将项目从budo(browserify)转换为生产?

时间:2018-12-07 06:03:30

标签: node.js browserify pm2 budo

nodejs的新手,刚刚使用npm包simple-peer完成了一个不错的练习,现在希望在生产环境(至少作为pm2下的服务)而不是在budo下运行它。

[我知道我需要改进代码以使其更适合大量生产使用,只是想让实时演示可靠地运行。]

如果我尝试通过这样做将index.js转换为bundle.js,

browserify index.js --output bundle.js 

然后

node bundle.js

我收到此错误

node bundle.js
start index.js
/home/ubuntu/peerchat/bundle.js:10
    initiator: location.hash === '#init',

           ^

ReferenceError:未定义位置

index.js在下面包含此内容

 var Peer = require('simple-peer');
  var peer = new Peer({
    initiator: location.hash === '#init',
    trickle: false//,
    //stream: stream
  })

其余代码在这里。 https://github.com/aspiringguru/peerchat.git

package.json包含此块

"scripts": {
    "start": "budo index.js:bundle.js"
  }

当前使用'npm start'可以正常运行,但是我想将其作为pm2下的服务运行。我怀疑我使用的是错误的工具,倾向于使用“更好的”工具或工作流而不是调试此特定代码。

0 个答案:

没有答案