browserify 不会编译 express js

browserify will not compile express js

我写了一个非常基础的 express.js 应用程序。然后试图使它成为一个 .js 文件。 Browserify 将整个事情编译成一个文件。但是 browserify 编译的代码不起作用。据我所知,browserify 只是用模块代码替换了 require 语句。错误是:

C:\Users\HP\n\express\app.js:27025
  __proto__: http.IncomingMessage.prototype
                                 ^

TypeError: Cannot read property 'prototype' of undefined
    at Object.__dirname.173.accepts (C:\Users\HP\n\express\app.js:27025:34)
    at s (C:\Users\HP\n\express\app.js:1:316)
    at C:\Users\HP\n\express\app.js:1:367
    at Object.__dirname.170../application (C:\Users\HP\n\express\app.js:26823:11)
    at s (C:\Users\HP\n\express\app.js:1:316)
    at C:\Users\HP\n\express\app.js:1:367
    at Object.__dirname.168../lib/express (C:\Users\HP\n\express\app.js:26154:18)
    at s (C:\Users\HP\n\express\app.js:1:316)
    at C:\Users\HP\n\express\app.js:1:367
    at Object.__dirname.153.express (C:\Users\HP\n\express\app.js:24010:15)

Browserify 专为浏览器打包代码而设计。

Node.js 支持许多浏览器不支持的模块,这些模块必须由 builtins 模拟。这些模块将被 browser-specific 填充程序替换。有些只提供在浏览器中有意义的节点 API 的一个子集。

所以你是 运行 一个应用程序,它已经转换了所有 Node.js 模块以支持 运行 它在浏览器中可以支持的功能,回到 Node 中,模块可用但不再使用。

尝试rollup or you could possibly configure babel按您需要的方式工作