I am using Pm2 and this is the error:
SyntaxError: Cannot use import statement outside a module
Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
The issue is, the package.json is already set to "type": "module".
Also, everything used to work fine until I restart the server.
Here is the actual .js file:
const http = require('http');
const url = require('url');
const querystring = require('querystring');
const hostname = 'localhost';
const port = 8080;
import captureWebsite from 'capture-website';
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World!\n');
....
});