Package management Flashcards

(7 cards)

1
Q

What is npm?

A

The Node Package Manager — a tool that comes with Node.js that lets you install and manage third-party code (packages) in your project.

npm install axios # installs the axios package

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you create a package.json and what is it?

A

It’s a file that describes your project and tracks which packages it depends on. Create it with:

npm init -y # -y skips the questions and uses defaults

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What happens when you run npm install axios?

A

Two things: it downloads the package into a node_modules folder, and it adds it to your package.json under dependencies.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is node_modules and should you commit it to Git?

A

The folder where npm stores all installed packages. Never commit it — it can be huge. Add it to .gitignore and anyone can recreate it by running npm install.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is semantic versioning?

A

The 3-number version system all npm packages use: MAJOR.MINOR.PATCH — e.g. 1.4.2.

PATCH (1.4.2) — bug fix, safe to update

MINOR (1.4.2) — new feature, backwards compatible

MAJOR (1.4.2) — breaking change, may require code updates

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is package-lock.json?

A

Auto-generated by npm. It locks the exact version of every installed package. This ensures everyone on your team installs the exact same versions when they run npm install.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are vulnerabilities in dependencies and how do you check for them?

A

Packages you install can have security flaws. Run npm audit to check, and npm audit fix to automatically fix safe ones. Always check this before deploying.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly