NPM Commands Flashcards

0
Q

Run commands from npm & package.json

Run multiple commands sequentially; run parallel

A
# package.json
# (`watch` will actually have mocha and node listening and print both results to console.)
{
  ...
  "scripts": {
    "test": "mocha --timeout=4000",
    "watch": "node server.js & mocha -w"
  }
}

npm run name will search inside the package.json script object for a property named name & execute the value. Even cooler, when the execution occurs, $PATH is manipulated to point to the current directory. This means even though we execute the mocha command, we do not have to have mocha installed globally! Awesome!

npm run test
npm run watch

To run commands sequentially, use the && operator; parallel, use &.
Example

# run mocha test THEN run jshint
mocha && jshint
# run mocha watch while running node watch
node server.js & mocha -w
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

Check if packages are outdated

A
# check all packages
npm outdated
# check single package
npm outdated name
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Default command to start server

Default command to run tests

A
# alias for npm run start
npm start
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Install package by package name

A

npm install name

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

Uninstall package by package name

A

npm rm name

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

Install packages in package.json file

Which packages are installed?

A

npm install

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

Install packages in package.json file

Which packages are installed?

A

npm install

Both dependencies & dev-dependencies are installed.

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

Uninstall package by package name and remove from package.json

A

npm rm name –save

npm rm name –save-dev

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

How to not install dev-dependencies?

A

npm install –production

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