`bcrypt` fails on installation with `node_modules`

Installation with existing node_modules directory fails with Cannot find module '../lib/main'

Hello šŸ™‚

I'm encountering an issue with the bcrypt package. I have a turborepo/monorepo with an api package and other apps. The package depends on bcrypt. Every time I want to add a new dependency to any app/package I have to remove the root node_modules folder and only then can I install it - reinstallation / adding a new package causes the error below:

> pnpm install <anything>

...

node_modules/bcrypt: Running install script, failed in 43ms
node_modules/bcrypt install$ node-pre-gyp install --fallback-to-build
│ node:internal/modules/cjs/loader:1078
│   throw err;
│   ^
│ Error: Cannot find module '../lib/main'
│ Require stack:
│ - /Users/peter/Developer/dinnery/node_modules/bcrypt/node_modules/.bin/node-pre-gyp
| ...
│ Node.js v18.16.0
└─ Failed in 44ms at /Users/peter/Developer/dinnery/node_modules/bcrypt


Indeed, the lib/main file does not exist.
Was this page helpful?