'Node+ExpressRouter -> CommonJS to ESM --> Import routes --> Error [ERR_MODULE_NOT_FOUND]: Cannot find module

I cant find my mistake after updating the node engine to 14.x and using ESM instead of CommonJS: exampleroute.js

import express from "express";
const router = express.Router();
router.get("/exampleroute", async (req, res) => {
  console.log('......')
})
export default router;

server.js

import http from "http";
import express from "express";
import exampleroute from "./routes/exampleroute";
const server = express();
server.use("/exampleroute", exampleroute);
const httpServer = http.createServer(server);
const httpPort = 8080
httpServer.listen(httpPort, () => console.log(`server is running @ port: ${httpPort}`));

Leads to: Error [ERR_MODULE_NOT_FOUND]: Cannot find module

What am I doing wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source