I'm trying to use express at my React-Typescript SPA. But It's giving me the error:
TypeError: Cannot read properties of undefined (reading 'prototype')
(anonymous function)
node_modules/express/lib/response.js:42
39 | * @public
40 | */
41 |
> 42 | var res = Object.create(http.ServerResponse.prototype)
43 |
44 | /**
45 | * Module exports.
I've tried adding target: "node" to my "node_modules/react-scripts/config/webpack.config.js" But it won't work...
Here's some ways I've already tried to solve it:
import express from "express";
app = express();
---------------
import express from "express";
let app: express.Application;
app = express();
-------------
import express from "express";
let app: any;
app = express();
-------------
const express require("express");
let app: express.Application;
app = express();
appwith const, var, or let for the first example, since it should work.import * as express from "express"