Ikshi / assignment

0 stars 0 forks source link

Containers failing to start #9

Open dlapin-cribl opened 1 month ago

dlapin-cribl commented 1 month ago

I tried running your solution but I'm getting this error from all containers

agent-1     | file:///usr/src/app/app.js:2
agent-1     | exports.__esModule = true;
agent-1     | ^
agent-1     | 
agent-1     | ReferenceError: exports is not defined in ES module scope
agent-1     | This file is being treated as an ES module because it has a '.js' file extension and '/usr/src/app/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
agent-1     |     at file:///usr/src/app/app.js:2:1
agent-1     |     at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
agent-1     |     at async ModuleLoader.import (node:internal/modules/esm/loader:475:24)
agent-1     |     at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:109:5)
agent-1     | 
agent-1     | Node.js v22.2.0

Can you think of the way to fix it?

Ikshi commented 1 month ago

@dlapin-cribl As defined in the package.json file, type has value module, thus it’s using the ES module. We should adjust the syntax according to ES module syntax instead of CommonJS module. In CommonJS the syntax to export module is exports.esModule = true whereas in ES module, it should be export const esModule = true;