You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mock-aws-s3, aws-sdk, nock dependencies vs devDependencies issue #661
Usage of mock-aws-s3, aws-sdk, and nock are used in the call stack originating from lib/node-pre-gyp.js (which is the package main), but they are only listed in "devDependencies".
I've encountered the same issue while trying to compile a back-end app with webpack for limited distribution. @johnmanko's analysis definitely looks correct to me.
Reacted by Tobi, Dylan Thorne, jahdiel, Sijmen and mndhvn
I encountered this issue when depending on bcrypt, which depends on @mapbox/node-pre-gyp and using rollup as a bundler. These seem to be unnecessary hard dependencies for this package.
Reacted by Gokan EKINCI, mppub, Benjamin Hall, Maxime Doury, Vicary, Rubek Joshi, Jack Michaud, Dries C, Jiyeol Lee, Josua Zurbrügg and 32 more
I encountered this issue using nest js. I solved it by removing webpack from compilerOptions
// I remove this block"compilerOptions": {"webpack": true}
Reacted by kbrown-medimap, Heiko, Thom, ADCREW LLC, Daniel Sitnik, João Paulo Furtado, AIMAN AFZAL, Prasad Suraj, Yehuda Makarov, wilsonandcompany and 15 more
I have encountered the same problem and opened an issue at bcrypt yesterday so they improve their README, but my bad I didn't know that was a recent node-pre-gyp issue. Anyway, dev dependencies should not be used in production files
I stumbled upon this as well when trying to bundle the DuckDB Node.js package. This additionally attempts to require npm as well :-/ I manually added nock and mock-aws-s3 as dev dependencies, and set npm as external. Then, it still complains that the package's dependencies html and cs files as well.
Using esbuild is seemingly also not an option, as this produces incorrect builds as well, due to node-pre-gyp...
Reacted by Matthew Fainman, Jonathan Ikpeazu, Dong Lucas, Boan Liang, Coji Mizoguchi, KirillZentsov, onbernard and Philipp Bisson
Hmmm. So i got same error while using bcrypt in a nuxt app. And i just kept on thinking what nuxt had to do with aws. It was frustrating. I just kept on searching online and stumbled at this
$ npm run build
shell: /usr/bin/bash -e {0}
> repro-node-pre-gyp-bcrypt-esbuild@1.0.0 build
> esbuild index.ts --bundle --platform=node --format=esm --target=node22 --outfile=out.js
Error: R] Could not resolve "mock-aws-s3"
node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:43:28:
43 │ const AWSMock = require('mock-aws-s3');
╵ ~~~~~~~~~~~~~
You can mark the path "mock-aws-s3" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.
Error: R] No loader is configured for".html" files: node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html
node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js:86:21:
86 │ return require('./' + command)(self, argvx, callback);
╵ ~~~~~~~~~~~~~~
Error: R] Could not resolve "aws-sdk"
node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:76:22:
76 │ const AWS = require('aws-sdk');
╵ ~~~~~~~~~
You can mark the path "aws-sdk" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.
Error: R] Could not resolve "nock"
node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:112:23:
112 │ const nock = require('nock');
╵ ~~~~~~
You can mark the path "nock" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.
4 errors
Error: Process completed with exit code 1.
same here, had the issue with bcrypt which depends on all of these (as dev deps), switched to bcryptjs and i'm finally moving forward after hours of debugging 😅
Activity
bhallstein commentedon Jul 11, 2022
I've encountered the same issue while trying to compile a back-end app with webpack for limited distribution. @johnmanko's analysis definitely looks correct to me.
gaberudy commentedon Jul 12, 2022
I encountered this issue when depending on
bcrypt, which depends on@mapbox/node-pre-gypand using rollup as a bundler. These seem to be unnecessary hard dependencies for this package.johnmanko commentedon Jul 12, 2022
@gaberudy
I ended up having to remove
bcryptand replaced it with the native nodecrypto:JustroX commentedon Sep 14, 2022
I encountered this issue using nest js. I solved it by removing
webpackfromcompilerOptionsbthibault commentedon Sep 22, 2022
+1
Karhide commentedon Sep 28, 2022
+1, encountered depending on node-sqlite3
eau-de-la-seine commentedon Oct 11, 2022
I have encountered the same problem and opened an issue at bcrypt yesterday so they improve their README, but my bad I didn't know that was a recent
node-pre-gypissue. Anyway, dev dependencies should not be used in production filestintinthong commentedon Nov 27, 2022
Is there a workaround for this issue? I face this problem
Glandos commentedon Dec 9, 2022
Bad workaround, add this to your webpack.config.js:
This will tell webpack to let the
requirecall as-is. It can obviously fail at runtime, and the required statement are still here.tintinthong commentedon Dec 10, 2022
Downside of this is that you need to handle all the runtime errors (like nested runtime dependencies) can take a long long time
tobilg commentedon Dec 12, 2022
I stumbled upon this as well when trying to bundle the DuckDB Node.js package. This additionally attempts to require
npmas well :-/ I manually addednockandmock-aws-s3as dev dependencies, and setnpmas external. Then, it still complains that the package's dependencies html and cs files as well.Using esbuild is seemingly also not an option, as this produces incorrect builds as well, due to
node-pre-gyp...NowyQuei commentedon Dec 13, 2022
some error here...
therealokoro commentedon Dec 31, 2022
Hmmm. So i got same error while using bcrypt in a nuxt app. And i just kept on thinking what nuxt had to do with aws. It was frustrating. I just kept on searching online and stumbled at this
martinszeltins commentedon Jan 12, 2023
I got this error using Vite and sqlite in an Electron.js app
61 remaining items
cclauss commentedon Feb 26, 2025
Can someone please add a GitHub Action to this repo that fails because of this problem? We all need to be able to see this failure.
karlhorky commentedon Feb 26, 2025
@cclauss I created a simple
bcrypt+@mapbox/node-pre-gyp+esbuildreproduction repo with failing CI over here:$ npm run build shell: /usr/bin/bash -e {0} > repro-node-pre-gyp-bcrypt-esbuild@1.0.0 build > esbuild index.ts --bundle --platform=node --format=esm --target=node22 --outfile=out.js Error: R] Could not resolve "mock-aws-s3" node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:43:28: 43 │ const AWSMock = require('mock-aws-s3'); ╵ ~~~~~~~~~~~~~ You can mark the path "mock-aws-s3" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time. Error: R] No loader is configured for ".html" files: node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js:86:21: 86 │ return require('./' + command)(self, argvx, callback); ╵ ~~~~~~~~~~~~~~ Error: R] Could not resolve "aws-sdk" node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:76:22: 76 │ const AWS = require('aws-sdk'); ╵ ~~~~~~~~~ You can mark the path "aws-sdk" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time. Error: R] Could not resolve "nock" node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:112:23: 112 │ const nock = require('nock'); ╵ ~~~~~~ You can mark the path "nock" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time. 4 errors Error: Process completed with exit code 1.package.json{ "name": "repro-node-pre-gyp-bcrypt-esbuild", "version": "1.0.0", "type": "module", "main": "index.js", "scripts": { "build": "esbuild index.ts --bundle --platform=node --format=esm --target=node22 --outfile=out.js" }, "dependencies": { "bcrypt": "5.1.1" }, "devDependencies": { "@types/bcrypt": "5.0.2", "esbuild": "0.25.0" } }index.tscclauss commentedon Feb 26, 2025
Awesome!!
Can you please also create a second job that tries
bcryptjsinstead ofbcryptso we can see the side-by-side results?#661 (comment)
karlhorky commentedon Feb 26, 2025
@cclauss done:
index-bcryptjs.tspackage.jsonscriptyoussefnassim commentedon Jul 4, 2025
same here, had the issue with bcrypt which depends on all of these (as dev deps), switched to bcryptjs and i'm finally moving forward after hours of debugging 😅
fix(ci): move to bcryptjs
fix(ci): move to bcryptjs
fix(ci): move to bcryptjs
fix(ci): move to bcryptjs
fix(ci): move to bcryptjs
fix(ci): move to bcryptjs
fix(ci): move to bcryptjs
feat: enable feature flag on announcement banner (#225)
fix(ci): move to bcryptjs
fix(ci): move to bcryptjs