npm Flashcards

1
Q

What is NPM?

A

software registry of packages

a command line interface

aka “The public npm registry is a database of JavaScript packages, each comprised of software and metadata. “

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

What is a package?

A

“The npm registry contains packages, many of which are also Node modules, or contain Node modules.”

aka

“A package is a file or directory that is described by a package.json file. A package must contain a package.json file in order to be published to the npm registry.”

aka

“Packages can be unscoped or scoped to a user or organization, and scoped packages can be private or public.”

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

How can you create a package.json with npm?

A

“You can create a package.json file by running a CLI questionnaire or creating a default package.json file”

“A package.json file:

  • lists the packages your project depends on
  • specifies versions of a package that your project can use using semantic versioning rules
  • 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
4
Q

What is a dependency and how do you add one to a package?

A
  1. dependencies: packages required by your application in production
  2. devDependencies: packages that are only needed for local development and testing

You can add dependencies to a package.json file from the command line or by manually editing the package.json file.

i.e.,

for production (see 1.)
npm install  [--save-prod]

for local development/testing (see 2.)
npm install –save-dev

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

What happens when you add a dependency to a package with npm?

A

your package.json file gets altered i.e., the dependency is added into to the “dependencies” attribute in your package.json file

creates a node_modules folder with the dependencies

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