Notice that packages can be installedThis command installs the newest available version of the named packages:
both locally or globally.
Local installation means that npm installs your package in the current working directory. Node modules go in ./node_modules, executables go in ./node_modules/.bin/. Usually you'll want to install local modules for usage inside your program, as a dependency, and they will work only on where they're installed.
npm install <package names>
Shorthand:
npm i <package names>
npm can interact with a package.json file in the current directory in various useful ways, through the objects dependencies and devDependencies stored in package.json (installing multiple modules):
The npm install command with no parameters
npm install
installs all packages named as object keys in the dependencies and devDependencies objects in package.json, using semantic versioning restrictions as indicated by the object values.
When developing new software:
Use option -S to append the <package names> and versions of npm modules you are installing that should always be included with your module. Appends to the list of dependencies tracked in the package.json file, after installing.
npm i <package names> -S
Use option -D to append the <package names> and versions of npm modules you are installing that are needed by other developers to further develop or test your module. Appends to the list of devDependencies tracked in the package.json file, after installing.
npm i <package names> -D
Where lodash and mocha are package names.