bullmq: Bullmq requires being in a node_modules folder, webpack output fails
If using bullmq and webpack, I get the following error:
[Error: ENOENT: no such file or directory, scandir 'node_modules/bullmq/dist/commands'] {
errno: -2,
code: 'ENOENT',
syscall: 'scandir',
path: 'node_modules/bullmq/dist/commands'
}
[Error: ENOENT: no such file or directory, scandir 'node_modules/bullmq/dist/commands'] {
errno: -2,
code: 'ENOENT',
syscall: 'scandir',
path: 'node_modules/bullmq/dist/commands'
}
[Error: ENOENT: no such file or directory, scandir 'node_modules/bullmq/dist/commands'] {
errno: -2,
code: 'ENOENT',
syscall: 'scandir',
path: 'node_modules/bullmq/dist/commands'
}
(node:1) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, scandir 'node_modules/bullmq/dist/commands'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:1) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, scandir 'node_modules/bullmq/dist/commands'
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
It seems that bullmq is trying to access the node_modules folder that doesn’t exist. Maybe imports should be updated?
A workaround when using webpack (at least with docker) is use the following dockerfile:
FROM node:lts-alpine
WORKDIR /app/src
COPY build.js .
COPY .env .
RUN npm init -y # added this to fix
RUN npm i bullmq # added this to fix
CMD ["node", "build.js"]
I’ll also add for anyone looking for the solution to the TypeError: n.updateDelaySet is not a function error, you need the following in your webpack module.exports since that error preceded this one in getting bullmq working with webpack and docker/kubernetes:
node: {
// required for __dirname to properly resolve
// Also required for `bull` to work, see https://github.com/OptimalBits/bull/issues/811
__dirname: true // and for bullmq to work
}
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (6 by maintainers)
Similar issue with
esbuild, bothbullandbullmqare one of the few packages that cannot be bundled. (Throws.addJob() is not a functionerror when bundle is executed)@ranjan-purbey https://github.com/taskforcesh/bullmq/issues/392#issuecomment-780579082, this had to be done for webpack if you didnt have the node modules when running the output. I would assume this is the same for esbuild (as i build esbuild with webpack)
in my bundler i have