NPM Commands Flashcards
Run commands from npm & package.json
Run multiple commands sequentially; run parallel
# 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
Check if packages are outdated
# check all packages npm outdated
# check single package npm outdated name
Default command to start server
Default command to run tests
# alias for npm run start npm start
Install package by package name
npm install name
Uninstall package by package name
npm rm name
Install packages in package.json file
Which packages are installed?
npm install
Install packages in package.json file
Which packages are installed?
npm install
Both dependencies & dev-dependencies are installed.
Uninstall package by package name and remove from package.json
npm rm name –save
npm rm name –save-dev
How to not install dev-dependencies?
npm install –production