Start learning free

LESSON 147 OF 173 · BACKEND: SHIPPING IT

package.json

Practice

On your computer, the shop runs with the packages you installed one day with npm install. A server starts empty. It installs the packages listed in a file named package.json, under "dependencies": one package per line, written "name": "version".

A version written in full, like "5.1.0", pins it: npm installs exactly that version, on every machine, not whatever is newest on the day it runs. (Left to itself, npm writes "^5.1.0", which means 5.1.0 or any newer 5.x.) What comes with Node.js, like node:sqlite, crypto and fetch, stays out of the file: those aren't packages npm can install. Here is the file of another project, a small bot that sends a newsletter:

{
  "name": "newsletter-bot",
  "dependencies": {
    "axios": "1.7.9",
    "node-cron": "3.0.3"
  }
}

In this lesson the file's content is a JavaScript object, packageJson, with every key in quotes, the way the file has them. The check reads it the way npm would and prints:

package.json:
{
  "name": "shop",
  "dependencies": {
    "express": "5.1.0",
    "express-session": "1.18.2",
    "multer": "2.0.2"
  }
}
npm install:
express 5.1.0: this exact version, on every machine
express-session 1.18.2: this exact version, on every machine
multer 2.0.2: this exact version, on every machine
The shop needs express (app.js requires it): pinned to 5.1.0
The shop needs express-session (the logins keep their sessions with it): pinned to 1.18.2
The shop needs multer (the photo uploads go through it): pinned to 2.0.2

Your task: pin the three packages the shop needs on a server, one per line inside "dependencies": express 5.1.0, express-session 1.18.2 (the logins keep their sessions with it) and multer 2.0.2 (the photo uploads go through it).


Assignment
Follow the Coding Tutorial to fill in packageJson, the content of the shop's package.json, with one pinned package per line.


Hint
Each line is the name in quotes, a colon, the version in quotes, and a comma at the end. No ^ in front of the version: the full version alone pins it.


STEP 1 OF 3
    Ctrl + Enter to check