There is something I fail to understand with ES6 modules in the context of node.js.
Let's say I have this simple node app. It is based on an iisnode example but I added an import
at the top.
hello.js:
import mod1 from './module1';
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(mod1.data);
}).listen(process.env.PORT);
This will result in SyntaxError: Cannot use import statement outside a module
However if I rename hello.js to hello.mjs I get the following error: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Program Files\iisnode\www\hellomodules\hello.mjs
Seems like a catch to me, what is the way out?
(iisnode version is 0.2.26, node version is v13.8.0)