Ardakilic / alerthub

AlertHub is a simple tool written with NodeJS to get alerted from new GitHub and GitLab repository events.
MIT License
202 stars 12 forks source link

Docker image latest crashes on startup #96

Open reconman opened 2 days ago

reconman commented 2 days ago

Since the changes on October 24th, the docker image cannot start anymore:

node:internal/modules/cjs/loader:1228


  throw err;

  ^

Error: Cannot find module '/app/node'

    at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)

    at Module._load (node:internal/modules/cjs/loader:1051:27)

    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)

    at node:internal/main/run_main_module:28:49 {

  code: 'MODULE_NOT_FOUND',

  requireStack: []

}

Node.js v20.18.0

There are 2 reasons:

  1. The node argument probably needs to be removed from the CMD line since the image already inherits the entrypoint /nodejs/bin/node, so the CMD should only be src/index.js.
  2. The app itself is never copied into any of the images, only the package.json is. You removed most of the COPY lines which also includes copying the javascript files into the image, so the image only consists of node and npm dependencies.

Even after fixing both, the container still crashes with:

(node:1) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/app/src/index.js:2
import RssFeedEmitter from 'rss-feed-emitter';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (node:internal/modules/cjs/loader:1378:20)
    at Module._compile (node:internal/modules/cjs/loader:1428:41)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Module._load (node:internal/modules/cjs/loader:1104:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
    at node:internal/main/run_main_module:28:49

Node.js v20.18.0

The reason why I renamed index.js to index.mjs 2 years ago was because of this error.

Ardakilic commented 2 days ago

Hello, thanks for the input. Please follow the tags for the time being. I know there are issues, but I have not released the version yet, and nowadays sadly I don't have time to focus on this. I'll take care of these as soon as I have more time from my work.