My app worked for several months without ANY problems.
It is very easy and has only:
- core.mjs - main app file
- config.json - settings file
core.mjs imports setting with this line: import config from "./config.json";
The app launches with the command: "node --experimental-modules core.mjs"
JSON is valid.
All files are on their places.
I can run this app locally and it will work.
But after deploying this on heroku it crashes on start. Here is the log:
2020-04-28T10:50:37.750749+00:00 app[worker.1]: (node:4) ExperimentalWarning: The ESM module loader is experimental.
2020-04-28T10:50:37.769400+00:00 app[worker.1]: internal/modules/run_main.js:57
2020-04-28T10:50:37.769402+00:00 app[worker.1]: internalBinding('errors').triggerUncaughtException(
2020-04-28T10:50:37.769402+00:00 app[worker.1]: ^
2020-04-28T10:50:37.769402+00:00 app[worker.1]:
2020-04-28T10:50:37.769403+00:00 app[worker.1]: TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".json" for /app/config.json
2020-04-28T10:50:37.769403+00:00 app[worker.1]: at Loader.defaultGetFormat [as _getFormat] (internal/modules/esm/get_format.js:70:15)
2020-04-28T10:50:37.769404+00:00 app[worker.1]: at Loader.getFormat (internal/modules/esm/loader.js:110:42)
2020-04-28T10:50:37.769404+00:00 app[worker.1]: at Loader.getModuleJob (internal/modules/esm/loader.js:241:31)
2020-04-28T10:50:37.769405+00:00 app[worker.1]: at async ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:44:17)
2020-04-28T10:50:37.769405+00:00 app[worker.1]: at async Promise.all (index 1)
2020-04-28T10:50:37.769406+00:00 app[worker.1]: at async link (internal/modules/esm/module_job.js:48:9) {
2020-04-28T10:50:37.769406+00:00 app[worker.1]: code: 'ERR_UNKNOWN_FILE_EXTENSION'
2020-04-28T10:50:37.769406+00:00 app[worker.1]: }
FIX WITHOUT JSON
When I tried to fix I just commented import string and copy-paste json object into core.mjs like: const config = {...};
This works but ruins all the concepts.
Any ideas of what to do with this json import problem? (without database)