I'm working with an old code base from an old project that uses bcrypt-as-promised
(before bcrypt
allowed the use of promises). When I try and npm install
the package.json
, I receive this error for that package:
npm WARN deprecated [email protected]: the bcrypt module supports promises now, this module is no longer necessary
npm WARN deprecated [email protected]: bcrypt < v2.0.0 is susceptible to bcrypt wrap-around bug. Upgrade to bcrypt >= v2.0.0 for improved support for newer bcrypt hashes
And then proceeds to fail (I can paste more of the error message if needed).
I'm a little confused as to how I might be able to get this now deprecated package to install. I thought about modifying the codebase to only use bcrypt
(with the now native promises supported), but I'm afraid of diving into a bee's nest and breaking the application. I was wondering first if there might be a way to install this package for the old code base to get it working.
Any thoughts? Thanks for your time and any insight you may have.
My package.json: https://github.com/twknab/mean_hike/blob/master/package.json
// Edit:
Here's the full terminal message I receive when I try and sudo npm install
:
> [email protected] install /var/www/mean_hike/node_modules/bcrypt
> node-gyp rebuild
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir
'/var/www/mean_hike/node_modules/bcrypt/build'
gyp ERR! System Linux 4.4.0-1072-aws
gyp ERR! command "/usr/local/bin/node"
"/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /var/www/mean_hike/node_modules/bcrypt
gyp ERR! node -v v11.2.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ubuntu/.npm/_logs/2018-11-27T10_46_27_925Z-debug.log
I found a solution to my issue was to use yarn
to import all of my dependencies rather than npm
, while also swapping bcrypt-as-promised
for bcrypt
(which now includes promises with no syntax changes necessary).
I ditched bcrypt-as-promised
and replaced it with bcrypt
in my package.json
file.
I then changed any instance of require('bcrypt-as-promised')
to require('bcrypt')
(the syntax for using bcrypt
remains the same, just the dependency importation lines need to change).
Without using yarn
, even after changing my folder permissions, I was still hitting permissions "EACCES: permission denied" errors, with only bcrypt
failing. My versions of npm and node seemed fine. Made sure my Ubuntu box was all updated.
That's when I gained the suggestion from a wise friend to try using yarn
to grab the dependencies instead. I ran yarn import
which reads the package.json
file and creates a yarn.lock
file. I then installed yarn
on my ubuntu machine (sudo npm install yarn -g
), and ran yarn install
, and bcrypt
successfully installed!
It looks like if npm
dependencies were originally installed using sudo
, permission issues can be experienced when trying to install bcrypt
. My improved solution was to:
./node_modules
folder via sudo rm -r ./node_modules
sudo
).npm i --save bcrypt
with the package installing
successfully.Here's a link from GitHub that helped me find the solution and an excerpt:
@Mayocampo permission denied, mkdir '/home/someroute/node_modules/bcrypt/build'
It seems you run rpm as root, therrfore your account cannot
mkdir
under /home/someroute/node_modules/ Check dir withls -l /home/someroute/node_modules/
Im sure owner of upper dir is root. or your account cannot have permission.I guess there are two options are available.
sudo rm -r ./node_modules
And install package via npm again, but without using sudo.- Change mod ./node_module to access and excutable. I decided first, and its fixed
Source: juicycool92 @ GitHub