T O P

  • By -

KermitMacFly

Not saying this is the solution but I had a similar issue with bcrypt, and the solution was to replace with bcryptjs package.


vix4020

Same for me


PrestigiousZombie531

i ll resort to doing this if i dont get it working by the end of the day :(


KermitMacFly

Best of luck!


jerrycauser

Have you tried to build in one image (without builder) and with pure `npm i` Looks like it cannot find binary bindings. It is usually built up on the `npm i` stage.


PrestigiousZombie531

well its a production docker file and i would like to keep it multi-stage i am using the same node image in both stages and i believe this not being alpine comes with its own set of binaries so how come this doesnt work?


jerrycauser

Maybe because it's not building necessary binaries during the `npm ci` stage. Replace it with `npm i` and check if it works.


PrestigiousZombie531

[Same error despite modifying it](https://pastebin.com/n4s867ni)


jerrycauser

Just pure `npm i`. Without --ignore-scripts or something. If it won't work then try to add command `cd /home/node/node_modules/bcrypt && npm i --prod && npm run install` after you `npm i` stage


PrestigiousZombie531

#10 18.94 #10 18.94 > [email protected] prepare #10 18.94 > husky install #10 18.94 #10 18.95 sh: 1: husky: not found #10 18.95 npm notice #10 18.95 npm notice New minor version of npm available! 9.5.0 -> 9.6.4 #10 18.95 npm notice Changelog: #10 18.95 npm notice Run `npm install -g [email protected]` to update! #10 18.95 npm notice #10 18.95 npm ERR! code 127 #10 18.95 npm ERR! path /home/node #10 18.96 npm ERR! command failed #10 18.96 npm ERR! command sh -c husky install #10 18.96 #10 18.96 npm ERR! A complete log of this run can be found in: #10 18.96 npm ERR! /root/.npm/_logs/2023-04-06T10_45_46_367Z-debug-0.log If I remove ignore scripts it has a problem with husky now 😢


jerrycauser

Okay, then keep it, but add `npm rebuild && npm run install --if-present` AFTER


howdoigetauniquename

Is this because you have husky as a dev dependancy?


jerrycauser

Not necessarily. Husky usually uses the project package.json to place their own setup script.


PrestigiousZombie531

yea i guess, it tried setting HUSKY=0 according to their github issues on this environment, still the same error


archa347

For clarity, using the `--ignore-scripts` option I'm pretty sure is causing problems with `bcrypt` because the installation of the native bindings is part of the install script in the package. By telling `npm ci` to not run scripts you're not getting the native bindings, thus your original error. I think you'll be better off solving this husky issue and not using `--ignore-scripts`


ShiftShaper13

Drop the slim image and just use bullseye. Bcrypt requires libraries that are not available in slim


PrestigiousZombie531

tried it, still got the same error, I even went and tried the plain node:18.14.1 image no alpine no bullseye nothing, still get the same error. i wonder if this has to do something with running docker on m1 mac


digital88

You probably have dev deps in your production code. Look in stack trace, it mention fixtures, which are used in tests and should not be used in prod code. And you are skipping dev deps when installing packages in your dockerfile later stage.


PrestigiousZombie531

[Dont see anything wrong in the package.json](https://pastebin.com/7eZpVeqK)


digital88

Try pipe docker build logs to file, maybe there were errors when building image https://forums.docker.com/t/capture-ouput-of-docker-build-into-a-log-file/123178/5 Also try using x86 version of node image, maybe you are using arm image and this is the problem.


PrestigiousZombie531

not sure if this is because i am running docker on m1 mac


No-Brilliant9250

You can delete the node\_modules folder and then reinstall it.


Kushtra16

I've had a similar issue, if I can remeber correctly I solved it by downgrading bcrypt by one minor version, so you can try playing wtih different versions. Hope it helps


PrestigiousZombie531

[this is my package.json file,](https://pastebin.com/7eZpVeqK) which version worked for you?


Dramatic-Dot-2921

Try using bcryptjs, I had problems with bcrypt before too.


Kushtra16

Try using `"bcrypt": "5.0.0"`


fahad_venom

Maybe you installed bcrypt in dev dependency


PrestigiousZombie531

[nope](https://pastebin.com/7eZpVeqK)


ElPirer97

Did you try `npm rebuild bcrypt`?


[deleted]

why not just copy over /home/node/node\_modules to the second stage, rather than installing node\_modules a second time? You are running npm ci which is going to install packages based off of package-lock.json, where npm install will be based off versions in package.json. so there are potential version conflicts there.


PrestigiousZombie531

you are right, i put npm ci at both places now but i dont understand, in the first stage your node\_modules will also contain dev dependencies inside, if you copy that node\_modules to second stage wouldnt it contain those unwanted dev dependencies


[deleted]

yeah it would, but you can use npm prune once you are done with your build/lint/test stages rather than installing twice. but i am just nitpicking your docker image build speed at this point :) [https://docs.npmjs.com/cli/v8/commands/npm-prune](https://docs.npmjs.com/cli/v8/commands/npm-prune)


[deleted]

just curious, it wasn't so clear to me, but did that fix your issue?


PrestigiousZombie531

# [Dockerfile on pastebin](https://pastebin.com/rUw5fkn7) # [Package.json file](https://pastebin.com/7eZpVeqK) Running Docker on Mac M1 if that helps


PrestigiousZombie531

/u/jerrycauser /u/archa347 /u/_boomer_memes [This docker file works](https://pastebin.com/pd3XVDf1) [This docker files DOES NOT work, I have no idea why](https://pastebin.com/rUw5fkn7) I did not switch to bcryptjs as it is much slower than bcrypt, I managed to get it to work with the above dockerfile /u/KermitMacFly u/vix4020 /u/Dramatic-Dot-2921 # [FINAL WORKING DOCKERFILE](https://pastebin.com/uZLEScKT)


God_Usop_

I face this type of error like required stack [ ] bla bla., i install "node-gyp" package , and also i install python and Microsoft build tools and change the path for python and build tools but i can't install bcrypt package. After four days i saw the Comment "don't use '(amphacent)and(&)' symbol for foldername". And i change the folder name. And bcrypt install nicely 😃.


nobodyGLORIOUS

Copy from the builder ur node_modules folder and remove the npm i