0

here is my server.js code

import express from 'express';
const app = express();
app.get('/', (req, res) => {
    res.send("dd")
   
});

app.listen()

And here is the error received:

/usr/local/lsws/fcgi-bin/lsnode.js:48
    var app = require(startupFile);
              ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/marcinek/xx/server.js from /usr/local/lsws/fcgi-bin/lsnode.js not supported.
Instead change the require of server.js in /usr/local/lsws/fcgi-bin/lsnode.js to a dynamic import() which is available in all CommonJS modules.
    at startApplication (/usr/local/lsws/fcgi-bin/lsnode.js:48:15)
    at Object.<anonymous> (/usr/local/lsws/fcgi-bin/lsnode.js:16:1) {
  code: 'ERR_REQUIRE_ESM'
}

I tried to add the "type": "module" entry in package.json and the .js and .mjs extensions, but it didn't help. Node version on server 18

Konrad
  • 21,590
  • 4
  • 28
  • 64

0 Answers0