I have a SvelteKit application that does not work after build. It is supposed to be run as a container. In one of the server endpoints I use bullmq client, which, after referenced, produces an error:
gui | ReferenceError: module is not defined in ES module scope
gui | This file is being treated as an ES module because it has a '.js' file extension and '/app/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
gui | at getPkgJsonDir (file:///app/build/server/chunks/_server-DJYoxZ8R.js:47284:40)
gui | at new ScriptLoader (file:///app/build/server/chunks/_server-DJYoxZ8R.js:46970:25)
gui | at file:///app/build/server/chunks/_server-DJYoxZ8R.js:47336:1
gui | at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
gui | at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
gui | at async respond (file:///app/build/server/index.js:3524:22)
gui | at async Array.ssr (file:///app/build/handler.js:1243:3)
I guess a package tries to load a CJS package and fails, but how can I find which package is responsible for the error?
Moving the bullmq package from dev dependencies into dependencies solved the problem.