Professional Documents
Culture Documents
NPM Crash
NPM Crash
"dependencies": {
"mongoose": "^5.10.0",
"underscore": "^1.10.2"
}
^ means:- major version should be 5 and if updated minor/patches are available, get it downloaded
[“~5.10.0”] ~ means: major should be 5, minor should be 10 and if latest patches are available, get it
download.
Exact version: do not use ^ or ~ then it will download the exact version specified.
Commands:
Npm view mongoose dependencies (shows only dependencies part from package.json of mongoose
library
Npm-check-updates –u (This will update package.json file to latest update, not installing the latest
version)
Development Dependencies:
These are type of packages that are useful in development but not required in production
So install these type of dependencies like
Npm I jshint –save-dev
In the package.json files these should be showing under development dependencies
Uninstall a package:
Npm uninstall [package_name]
Or
Npm un [package_name]
Global Package:
Npm I –g [package_name]
Npm –g outdated
Publish a package:
1. Create new directory
2. Npm init –yes
3. Create new file index.js
Module.exports.add = function(a, b) { return a + b};
Republish a package:
1. Open index.js
Module.exports.multiply = function(a, b) { return a * b };
Useful packages
Used for validations of email addresses, Phone numbers, Soccial Security numbers, Credit Card numbers
etc