require works but import does not work in node js version 14+

Viewed 429

everything works very fine in the localhost with the node 14.

But when i try to host it to the cpanel using es6 import, it fails and gives the error like,

RangeError: WebAssembly.instantiate(): Out of memory: wasm memory
    at internal/deps/cjs-module-lexer/dist/lexer.js:1:33272
    at async initCJSParse (internal/modules/esm/translators.js:67:5)
    at async Loader.commonjsStrategy (internal/modules/esm/translators.js:181:18)

It is very weird.

package.json file

{
  "name": "practice",
  "version": "1.0.0",
  "description": "",
  "type":"module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "run": "node index.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.17.1"
  }
}

index.js file

import express from "express";
const app = express();
const port = 3000;

app.get("/", (req, res) => {
  res.send("Hello World test2");
});

app.listen();

debug log enter image description here need some help hosting my nodejs app to cpanel

0 Answers
Related