Understand BCrypt Hashes

Understand BCrypt Hashes
0

#1

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].)


#2

did you install BCrypt?

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


#3

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


#4

what error are you getting?


#5

It says “error error”


#6

how did you get the version of the BCrypt?


#7

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


#8

To add a package

cd into the directory of your project

npm install package --save(optional)


#9

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


#10

Do I add it on server.js?


#11

change the var to const

run npm install


#12

did FCC give you the version of BCrypt to add?


#13

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"
  ]
}

#14

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

and this too

request.query.dream?


#15

the version is right


#16

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


#17

then you are not doing anything wrong

did you run npm start at the terminal?


#18

How do I run npm start and where is terminal?


#19

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


#20

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