I have an application which uses esm modules and import statements. It runs fine in development using the --experimental-modules flag with nodemon, but when I run it in production using forever the imports fail because I don't know where to put the flag. When I run npm run build with the package.json as below it says sh: --experimental-modules: command not found.
If I add --experimental-modules to the "script" part of forever-config.json it says the same thing.
I've searched the internet several times. How do use the --experimental-modules flag with forever? I'm running Node v10.16.0.
{
"type": "module",
"name": "application_name",
"version": "1.0.0",
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "concurrently \"npm run build:dev\" \"npm run start-server:dev\"",
"build": "npm run build:prod && npm run start-server:prod",
"build:dev": "webpack --config webpack-dev.config.js",
"build:prod": "webpack -p --config webpack-prod.config.js",
"start-server:dev": "NODE_ENV=development nodemon --config nodemon.json --experimental-modules src/server/index.mjs ",
"start-server:prod": "NODE_ENV=production --experimental-modules forever -o ./forever-out.log -e ./forever-error.log start forever-config.json"
},
//rest of package.json left out for brevity
}
forever-config.json
{
"uid": "application_name",
"max": 5,
"spinSleepTime": 1000,
"minUptime": 1000,
"append": true,
"watch": false,
"script": "src/server/index.mjs"
}