0

I have been struggling to install bcrypt all weekend. Over the course of the weekend I have updated Node to version 10.15.3 (and npm 6.4.1).

A possible solution is to forget about bcrypt and install bcryptjs. My (perhaps unfounded?) concern is that the latest version (2.4.3) of bcryptjs is 2 years old whereas bcrypt has the benefit of continuous support. I would like to use bcrypt in my project.

Here is the error I got:

vagrant [server]> npm install bcrypt
npm WARN server@1.0.0 No description
npm WARN server@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! path /vagrant/barbershop-pevn/server/node_modules/bcrypt/node_modules/minipass/node_modules/yallist/package.json.3160920247
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/vagrant/barbershop-pevn/server/node_modules/bcrypt/node_modules/minipass/node_modules/yallist/package.json.3160920247'

On the server folder...

package.json

{
    "name": "server",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
        "start": "./node_modules/nodemon/bin/nodemon.js src/app.js --exec 'npm run lint && node'",
        "lint": "./node_modules/.bin/eslint \"**/*.js\""
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "dependencies": {
        "body-parser": "^1.18.3",
        "cors": "^2.8.5",
        "dotenv": "^7.0.0",
        "express": "^4.16.4",
        "joi": "^14.3.1",
        "jsonwebtoken": "^8.5.0",
        "morgan": "^1.9.1",
        "pg": "^7.9.0",
        "pg-hstore": "^2.3.2",
        "semver": "^5.6.0",
        "sequelize": "^5.1.0"
    },
    "devDependencies": {
        "eslint": "^5.15.3",
        "eslint-config-airbnb-base": "^13.1.0",
        "eslint-plugin-import": "^2.16.0",
        "eslint-plugin-vue": "^5.2.2",
        "nodemon": "^1.18.10"
    }

}

npm list -g --depth=0 returns:

/home/vagrant/.nvm/versions/node/v10.15.3/lib
├── @vue/cli@3.5.0
├── @vue/cli-init@3.5.0
├── http-server@0.11.1
├── node-gyp@3.8.0
├── npm@6.4.1
├── npm-check@5.9.0
└── npx@10.2.0

cat /etc/*release returns:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.6 LTS"
NAME="Ubuntu"
VERSION="16.04.6 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.6 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial

OS of my mac: 10.13.6

MAJOR EDIT 1:

I did the following:

vagrant [server]> sudo apt install node-gyp

And then I got this error:

vagrant [server]> npm install bcrypt
npm WARN server@1.0.0 No description
npm WARN server@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! path /vagrant/barbershop-pevn/server/node_modules/bcrypt/node_modules/minipass/node_modules/safe-buffer/package.json.3118274111
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/vagrant/barbershop-pevn/server/node_modules/bcrypt/node_modules/minipass/node_modules/safe-buffer/package.json.3118274111'

What am I missing? Any help that allows for the installation of bcrypt or at least points me in the right direction is greatly appreciated.

Rot-man
  • 18,045
  • 12
  • 118
  • 124
cocomatt
  • 131
  • 1
  • 2
  • 11
  • you shouldn't need `node-gyp`, that shouldn't be the issue. 1) Can you try creating a new project and seeing if you can install `bcrypt` there? `cd ~/workspace && mkdir testBcrypt && cd testBcrypt && npm init -y && npm i bcrypt` - post results here. 2) have you tried `rm -rf node_modules && npm i`? – JBallin Mar 18 '19 at 21:21
  • @JBallin Thanks for the reply. I did as requested and got this error: `vagrant [testBcrypt]> npm i bcrypt npm WARN testBcrypt@1.0.0 No description npm WARN testBcrypt@1.0.0 No repository field. npm ERR! path /vagrant/testBcrypt/node_modules/bcrypt/node_modules/minipass/node_modules/safe-buffer/package.json.4269958338 npm ERR! code ENOENT npm ERR! errno -2 npm ERR! syscall open npm ERR! enoent ENOENT: no such file or directory, open '/vagrant/testBcrypt/node_modules/bcrypt/node_modules/minipass/node_modules/safe-buffer/package.json.4269958338'` – cocomatt Mar 18 '19 at 21:35
  • @JBallin I have also `rm -rf node_modules && npm i` a million times, restarted terminal, restarted VSCode, restarted my laptop about the same number of times as well – cocomatt Mar 18 '19 at 21:36
  • are you able to install other packages without issue? If you start a new project, can you run `npm i cowsay` successfully? I would focus on getting bcrypt to work in a clean project first, and consider deleting the global npm packages. I would also try `which node` and `which npm` to make sure they're coming from where I suspect they are. – JBallin Mar 18 '19 at 21:41
  • another option, is to try installing `bcrypt.js` instead of `bcrypt`, which has 0 dependencies and is sometimes used when there are issues installing `bcrypt`. https://www.npmjs.com/package/bcryptjs – JBallin Mar 18 '19 at 21:43
  • @JBallin I was able to install cosway just fine. `which node` /home/vagrant/.nvm/versions/node/v10.15.3/bin/node `which npm` /home/vagrant/.nvm/versions/node/v10.15.3/bin/npm – cocomatt Mar 18 '19 at 21:43
  • I uninstalled all global packages except npm and I still got the same error `npm ERR! enoent ENOENT: no such file or directory, open '/vagrant/testBcrypt/node_modules/bcrypt/node_modules/minipass/node_modules/yallist/package.json.2993738945'` – cocomatt Mar 18 '19 at 21:53
  • Did you try `npm i bcryptjs` (mentioned above)? – JBallin Mar 18 '19 at 22:16
  • I did. I got the error message that is quoted before your last message – cocomatt Mar 18 '19 at 22:28
  • 1
    Instead of installing dependencies using npm, can you try yarn. Atleast it will narrow down the issue, whether it is regarding with package installation with npm or some other issue. – Mohit Tilwani Mar 18 '19 at 22:30
  • @cocomatt that error message says `bcrypt` and shows an issue with the `minipass` dependency. `bcryptjs` has 0 dependencies. – JBallin Mar 18 '19 at 22:37
  • Related questions: https://stackoverflow.com/q/50635925/4722345, https://stackoverflow.com/questions/20960546/cannot-install-bcrypt-ruby-on-vagrant-machine, https://stackoverflow.com/questions/34568345/ubuntu-and-bcrypt – JBallin Mar 18 '19 at 22:41
  • @MohitTilwani I had to install yarn v1.15.2 and it worked! `success Saved lockfile. success Saved 3 new dependencies. info Direct dependencies └─ bcrypt@3.0.4 info All dependencies ├─ bcrypt@3.0.4 ├─ nan@2.12.1 └─ node-pre-gyp@0.12.0` I have never used yarn before. Should I use yarn on the client-side of my project now? Can I somehow revert back to NPM? – cocomatt Mar 18 '19 at 22:46
  • yarn is basically the same as npm (other than the visuals), you can use either interchangeably. Just make sure you only have one lock file (`yarn.lock` vs. `package-lock.json`). https://yarnpkg.com/lang/en/docs/migrating-from-npm/ – JBallin Mar 18 '19 at 23:00
  • 1
    Using yarn just because npm is throwing an error for installing dependency doesn’t make sense, as maybe later yarn coukd throw error for some dependency and then you shouldn’t think of switching to npm. I think the issue is something with node or npm version. Can you try with node lower version like 8 something and npm version 5 something and see if you are still facing the issue – Mohit Tilwani Mar 18 '19 at 23:01
  • @MohitTilwani I agree; NPM install should work. On NodeJS 8.15.1 and NPM 5.10.0 I just tried to install bcrypt onto a project with no dependencies and this is the error: `npm ERR! path /vagrant/testBcrypt/node_modules/bcrypt/node_modules/minipass/node_modules/yallist/package.json.4166652717 npm ERR! code ENOENT npm ERR! errno -2 npm ERR! syscall open npm ERR! enoent ENOENT: no such file or directory, open '/vagrant/testBcrypt/node_modules/bcrypt/node_modules/minipass/node_modules/yallist/package.json` – cocomatt Mar 19 '19 at 01:46

1 Answers1

0

I think this is an npm issue. I can successfully install bcrypt using yarn or pnpm (which looks rather attractive) on NodeJS versions 8.15.1 and 10.15.3. My question was about installing bcrypt (not necessarily using npm) so I'm going to say I got a satisfactory answer for the time being: Use yarn or pnpm (or just install brcyptjs). I have raised an issue on github.

cocomatt
  • 131
  • 1
  • 2
  • 11