As explained earlier node-js expects common.js import style until version 14 so no import / export keywords could work before.
In order to convert our import statements, either you could rely on a bundler like webpack/parcel/rollup or you could transpile your files using babel.
Here using babel and babel-node for instance, you can add the following dependencies:
"devDependencies": {
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/node": "^7.12.6",
"@babel/plugin-transform-modules-commonjs": "^7.12.1",
"@babel/preset-env": "^7.12.1"
}
then add a babel.config.js at the root containing:
module.exports = function (api) {
api.cache(false);
return {
presets: [ "@babel/preset-env" ],
plugins: [ "@babel/plugin-transform-modules-commonjs" ],
};
}
Now in your start command replace node by babel-node:
"start": "babel-node -i [] dist/index.js",
-i [ ]
will help transpiling file from the node_modules folder as well.
But as a general way here using a bundler like you would do for the web might make things easier