Error when using in a Vue project. Webpack related?

Hi.
I’m facing a problem whenever I simply const express = require('express') in the main.js file inside a fresh made vue project configured through the vue cli, with webpack included. So, I’m not sure if I should report this issue here or there. Please excuse me if this shouldn’t belong here.
Firefox and Chrome give me different errors, both pointing to express.
Here is the Chrome error:

response.js?7b38:42 Uncaught TypeError: Cannot read property 'prototype' of undefined
    at eval (response.js?7b38:42)
    at Object../node_modules/express/lib/response.js (app.js:3643)
    at __webpack_require__ (app.js:768)
    at fn (app.js:131)
    at eval (express.js?28ec:22)
    at Object../node_modules/express/lib/express.js (app.js:3595)
    at __webpack_require__ (app.js:768)
    at fn (app.js:131)
    at eval (index.js?b97d:11)
    at Object../node_modules/express/index.js (app.js:3560)

and here is the Firefox error:

TypeError: http.ServerResponse is undefined[Weitere Informationen] app.js line 3643 > eval:42:5
<anonym>
response.js:42
./node_modules/express/lib/response.js
http://localhost:8080/app.js:3643:1
__webpack_require__
http://localhost:8080/app.js:768:12
fn
http://localhost:8080/app.js:131:20
<anonym>
express.js:22
./node_modules/express/lib/express.js
http://localhost:8080/app.js:3595:1
__webpack_require__
http://localhost:8080/app.js:768:12
fn
http://localhost:8080/app.js:131:20
<anonym>
index.js:11
./node_modules/express/index.js
http://localhost:8080/app.js:3560:1
__webpack_require__
http://localhost:8080/app.js:768:12
fn
http://localhost:8080/app.js:131:20
<anonym>
main.js:8
./src/main.js
http://localhost:8080/app.js:6043:1
__webpack_require__
http://localhost:8080/app.js:768:12
fn
http://localhost:8080/app.js:131:20
0
http://localhost:8080/app.js:6128:18
__webpack_require__
http://localhost:8080/app.js:768:12
<anonym>
http://localhost:8080/app.js:904:18
<anonym>
http://localhost:8080/app.js:1:11

Author: Fantashit

1 thought on “Error when using in a Vue project. Webpack related?

  1. Express is a server library, not a client library. You want to run it in Node.js on the server side and not in a web browser on the client side.

Comments are closed.