Understand BCrypt Hashes

Okay,I did var bcrypt = require('bcrypt')
In the server.js
Then,I added BCrypt into Dependencies part
like this:
"dependencies": { "express": "^4.16.3", "bcrypt": "^3.0.1" },
So,WHAT is the problem???
(Note: And yes,I did on the link FreeCode camp has given [Glitch].)

did you install BCrypt?

You have to do npm i BCrypt --save in your terminal to have the package

How do I do that?
Can you tell me how can I do it?
Do I install it by “Add Package” button?

what error are you getting?

It says “error error”

how did you get the version of the BCrypt?

Like I added it on dependencies part in package.json and I required it in server.

To add a package

cd into the directory of your project

npm install package --save(optional)

So the code is…npm install packagae-- save(optional)??

Do I add it on server.js?

change the var to const

run npm install

did FCC give you the version of BCrypt to add?

No,which version should it be?
Code:

// server.js
// where your node app starts

// init project
const bcrypt = require('bcrypt')
const express = require('express')
const app = express()

// we've started you off with Express, 
// but feel free to use whatever libs or frameworks you'd like through `package.json`.

// http://expressjs.com/en/starter/static-files.html
app.use(express.static('public'))

// http://expressjs.com/en/starter/basic-routing.html
app.get("/", (request, response) => {
  response.sendFile(__dirname + '/views/index.html')
})

// Simple in-memory store
const dreams = [
  "Find and count some sheep",
  "Climb a really tall mountain",
  "Wash the dishes"
]

app.get("/dreams", (request, response) => {
  response.send(dreams)
})

// could also use the POST body instead of query string: http://expressjs.com/en/api.html#req.body
app.post("/dreams", (request, response) => {
  dreams.push(request.query.dream)
  response.sendStatus(200)
})

// listen for requests :)
const listener = app.listen(process.env.PORT, () => {
  console.log(`Your app is listening on port ${listener.address().port}`)
})
for json part:
{
  "//1": "describes your app and its dependencies",
  "//2": "https://docs.npmjs.com/files/package.json",
  "//3": "updating this file will download and update your packages",
  "name": "my-glitch-app",
  "version": "0.0.1",
  "description": "What am I about?",
  "scripts": {
    "start": "node server.js"
  },
  "dependencies": {
    "express": "^4.16.3",
    "bcrypt": "^3.0.1"
  },
  "engines": {
    "node": "9.x"
  },
  "repository": {
    "url": "https://glitch.com/edit/#!/my-glitch-app"
  },
  "license": "MIT",
  "keywords": [
    "node",
    "glitch",
    "express"
  ]
}

listener.address().port? where did this come from?

and this too

request.query.dream?

the version is right

It was already in there when I clicked the link FCC gave in the server.js

then you are not doing anything wrong

did you run npm start at the terminal?

How do I run npm start and where is terminal?

It sounds like the node package hasn’t been installed. Did you run the npm command to install the bcrypt package in node_modules?

Open up your terminal or command prompt, cd into your project folder root folder, and use npm install bcrypt --save

1 Like

OMG thanks.@DanStockham.I haven’t thought about that…