npm Flashcards

1
Q
  1. What is NPM?
A

a. Trick question – you should ask… what part of the npm?
b. NPM is the world’s largest software registry. It consists of three distinct components:
i. The website
1. The website is used to discover packages, set up profiles, and manage other aspects of your npm experience.

ii. The Command Line Interface (CLI)
1. The CLI runs from a terminal, and is how most developers interact with npm.

iii. The registry
1. The registry is a large public database of JavaScript software and the meta-information surrounding it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. What is a package?
A

a. A directory with one or more files PLUS a package.json file – Tim.
b. A package.json file
i. lists the packages your project depends on
ii. specifies versions of a package that your project can use using semantic versioning rules
iii. makes your build reproducible, and therefore easier to share with other developers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. How can you create a package.json with npm?
A

a. To create a package.json file with values that you supply, use the npm init command.
i. On the command line, navigate to the root directory of your package.
1. cd /path/to/package
ii. Run the following command.
1. npm init
iii. Answer the questions in the command line questionnaire.
iv. To create a default package.json file
1. On the command line, navigate to the root directory of the package.
a. cd /path/to/package
2. Run the following command:
a. npm init – yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. What is a dependency and how to you add one to a package?
A

a. A third party code that your project relies on to function properly - Tim

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  1. What happens when you add a dependency to a package with npm?
A

a. It downloads the package from the registry, installs the dependencies into the nod_modules folder and updates package.json to list that package dependency.
b. When you (or another user) run npm install , npm will download dependencies and devDependencies that are listed in package. json that meet the semantic version requirements listed for each.
c. For more information on semantic version requirements  https://semver.org/

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