Installing Express
Express arrives with one npm command. npm is the installer that adds Node libraries.
The install command
This command installs Express. Run it in a terminal.
npm install expressThe version check
This code prints the installed Express version.
const info = require('express/package.json');
console.log(info.version);Example
const info = require('express/package.json');
console.log(info.version);
console.log('Express is installed');Key points
- Use npm install express to install Express.
- npm runs in a terminal, never inside a Node file.
- A terminal runs typed commands at a prompt.
- The install adds Express to the project folder.
- Run a short version check in Node after the install.
- Version numbers carry three parts, like 5.3.0.
In this example, info reads the installed Express details. The first print shows 5.3.0, the installed version. The last line prints Express is installed.
Note
If the check fails, Express is missing, so install it once more.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
Which command installs Express?