browserify无法编译Express js [英] browserify will not compile express js

查看:57
本文介绍了browserify无法编译Express js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个非常基本的express.js应用程序。然后尝试使其成为一个.js文件。 Browserify将整个内容编译到一个文件中。但是用browserify编译的代码无法正常工作。据我所知,browserify只是用模块代码代替了require语句。错误是:

I wrote a very basic express.js app. Then tried to make it one .js file. Browserify compiled the whole thing to a one file. But browserify-compiled code didn't work. As far as I know, browserify just replaces require statements with module codes. Error is:

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 是des

Node.js支持许多浏览器不需要的模块,这些模块不必由内建。这些模块将被特定于浏览器的填充程序取代。有些只提供了在浏览器中有意义的Node API的子集。

Node.js supports a number of modules that a browser doesn't which have to be emulated by builtins. These modules will be replaced by a browser-specific shim. Some only supply a subset of the Node API that makes sense to have in a browser.

因此,您正在运行一个应用程序,该应用程序已转换所有Node.js模块,以支持在浏览器中运行它所能执行的操作,然后返回到Node可用的模块中,但是不再使用。

So you are running an app that has converted all the Node.js modules to support running what it can in a browser, back in Node where the modules are available but are no longer being used.

尝试汇总,否则您可以配置 babel 可以根据需要工作

Try rollup or you could possibly configure babel to work like you need

这篇关于browserify无法编译Express js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆