w3resource
gallery w3resource

Node Package Manager - Commands - slides presentation

npm is Node Package Manager or NodeJS package manager, is the default package manager for Node.js. npm runs through the command line and it makes it easier to specify and link dependencies.

Transcript

npm

npm is the package manager for the Node JavaScript platform. It puts modules in place so that node can find them, and manages dependency conflicts intelligently.
Syntax : - npm [args]
Version : - 2.1.0

npm - adduser

Create or verify a user named in the specified registry, and save the credentials to the .npmrc file. If no registry is specified, the default registry will be used (see npm-config(7)).
Syntax : - npm adduser [--registry=url] [--scope=@orgname] [--always-auth]

npm - bin

Print the folder where npm will install executables.
Syntax : - npm bin

npm - bugs

This command tries to guess at the likely location of a package's bug tracker URL, and then tries to open it using the --browser config param. If no package name is provided, it will search for a package.json in the current folder and use the name property.
Syntax : - npm bugs <pkgname>
npm bugs (with no args in a package dir)

npm - build

This is the plumbing command called by npm link and npm install. It should generally not be called directly.
Syntax : - npm build <package-folder>

npm - cache

Used to add, list, or clear the npm cache folder.
Syntax : - npm cache add <tarball file>
npm cache add <folder>
npm cache add <tarball url>
npm cache add <name>@<version>
npm cache ls [<path>]
npm cache clean [<path>]

npm - completion

Enables tab-completion in all npm commands.
Syntax : - . <(npm completion)

npm - config

npm gets its config settings from the command line, environment variables, npmrc files, and in some cases, the package.json file.
Syntax : - npm config set <key> <value> [--global] npm config get <key> npm config delete <key> npm config list npm config edit npm c [set|get|delete|list] npm get <key> npm set <key> <value> [--global]

npm - debupe

Searches the local package tree and attempts to simplify the overall structure by moving dependencies further up the tree, where they can be more effectively shared by multiple dependent packages.
Syntax : - npm dedupe [package names...]
npm ddp [package names...]

npm - deprecate

This command will update the npm registry entry for a package, providing a deprecation warning to all who attempt to install it.
Syntax : - npm deprecate <name>[@<version>] <message>

npm - docs

This command tries to guess at the likely location of a package's documentation URL, and then tries to open it using the --browser config param. You can pass multiple package names at once. If no package name is provided, it will search for a package.json in the current folder and use the name property.
Syntax : - npm docs [<pkgname> [<pkgname> ...]]
npm docs (with no args in a package dir)
npm home [<pkgname> [<pkgname> ...]]
npm home (with no args in a package dir)

npm - edit

Opens the package folder in the default editor (or whatever you've configured as the npm editor config -- see npm-config(7).)
Syntax : - npm edit <name>[@<version>]

npm - explore

Spawn a subshell in the directory of the installed package specified. Syntax : - npm explore <name> [ -- <cmd>]

npm - help - search

This command will search the npm markdown documentation files for the terms provided, and then list the results, sorted by relevance.
Syntax : - npm help-search some search terms

npm - help

If supplied a topic, then show the appropriate documentation page.
Syntax : - npm help <topic>
npm help some search terms

npm - init

This will ask you a bunch of questions, and then write a package.json for you.
Syntax : - npm init [-f|--force|-y|--yes]

npm - install

This command installs a package, and any packages that it depends on. If the package has a shrinkwrap file, the installation of dependencies will be driven by that.
Syntax : - npm install (with no args in a package dir)
npm install <tarball file>
npm install <tarball url>
npm install <folder>
npm install [@<scope>/]<name>
[--save|--save-dev|--save-optional] [--save-exact]
npm install [@<scope>/]<name>@<tag>
npm install [@<scope>/]<name>@<version>
npm install [@<scope>/]<name>@<version range>
npm i (with any of the previous argument usage)

npm - link

Package linking is a two-step process.
First, npm link in a package folder will create a globally-installed symbolic link from prefix/package-name to the current folder.
Next, in some other location, npm link package-name will create a symlink from the local node_modules folder to the global symlink.
Syntax : - npm link (in package folder)
npm link [@<scope>/]<pkgname>
npm ln (with any of the previous argument usage)

npm - ls

This command will print to stdout all the versions of packages that are installed, as well as their dependencies, in a tree-structure. Syntax : - npm list [[@<scope>/]<pkg> ...] npm ls [[@<scope>/]<pkg> ...] npm la [[@<scope>/]<pkg> ...] npm ll [[@<scope>/]<pkg> ...]

npm - outdated

This command will check the registry to see if any (or, specific) installed packages are currently outdated.
Syntax : - npm outdated [<name> [<name> ...]]

npm - owner

Manage ownership of published packages.
ls: List all the users who have access to modify a package and push new versions. Handy when you need to know who to bug for help. add: Add a new user as a maintainer of a package. This user is enabled to modify metadata, publish new versions, and add other owners.
rm: Remove a user from the package owner list. This immediately revokes their privileges.
Syntax : - npm owner ls <package name>
npm owner add <user> <package name>
npm owner rm <user> <package name>

npm - pack

For anything that's installable (that is, a package folder, tarball, tarball url, name@tag, name@version, or name), this command will fetch it to the cache, and then copy the tarball to the current working directory as <name>-<version>.tgz, and then write the filenames out to stdout.
Syntax : - npm pack [<pkg> [<pkg> ...]]

npm - prefix

Print the local prefix to standard out. This is the closest parent directory to contain a package.json file unless -g is also specified.
Syntax : - npm prefix [-g]

npm - prune

This command removes "extraneous" packages. If a package name is provided, then only packages matching one of the supplied names are removed.
Syntax : - npm prune [<name> [<name ...]]
npm prune [<name> [<name ...]] [--production]

npm - publish

Publishes a package to the registry so that it can be installed by name.
Syntax : - npm publish <tarball> [--tag <tag>] npm publish <folder> [--tag <tag>]

npm - rebuild

This command runs the npm build command on the matched folders. This is useful when you install a new version of node, and must recompile all your C++ addons with the new binary.
Syntax : - npm rebuild [<name> [<name> ...]]
npm rb [<name> [<name> ...]]

npm - repo

This command tries to guess at the likely location of a package's repository URL, and then tries to open it using the --browser config param. If no package name is provided, it will search for a package.json in the current folder and use the name property.
Syntax : - npm repo <pkgname>
npm repo (with no args in a package dir)

npm - restart

This runs a package's "restart" script, if one was provided. Otherwise it runs package's "stop" script, if one was provided, and then the "start" script.
Syntax : - npm restart [-- <args>]

npm - rm

This uninstalls a package, completely removing everything npm installed on its behalf.
Syntax : - npm rm <name>
npm r <name>
npm uninstall <name>
npm un <name<

npm - root

Print the effective node_modules folder to standard out.
Syntax : - npm root

npm - run - script

This runs an arbitrary command from a package's "scripts" object. If no package name is provided, it will search for a package.json in the current folder and use its "scripts" object. If no "command" is provided, it will list the available top level scripts.
Syntax : - npm run-script [command] [-- <args>]
npm run [command] [-- <args>]

npm - search

Search the registry for packages matching the search terms. If a term starts with ‘/’, then it's interpreted as a regular expression. A trailing ‘/’ will be ignored in this case. (Note that many regular expression characters must be escaped or quoted in most shells.)
Syntax : - npm search [--long] [search terms ...]
npm s [search terms ...]
npm se [search terms ...]

npm - shrinkwrap

This command locks down the versions of a package's dependencies so that you can control exactly which versions of each dependency will be used when your package is installed. The "package.json" file is still required if you want to use "npm install".
Syntax : - npm shrinkwrap

npm - star

"Starring" a package means that you have some interest in it. It's a vaguely positive way to show that you care.
Syntax : - npm star <pkgname> [<pkg>, ...] npm unstar <pkgname> [<pkg>, ...]

npm - stars

If you have starred a lot of neat things and want to find them again quickly this command lets you do just that.
Syntax : - npm stars
npm stars [username]

npm - start

This runs a package's "start" script, if one was provided.
Syntax : - npm start [-- <args>]

npm - stop

This runs a package's "stop" script, if one was provided.
Syntax : - npm stop [-- <args>]

npm - submodule

If the specified package has a git repository url in its package.json description, then this command will add it as a git submodule at node_modules/<pkg name>.
Syntax : - npm submodule <pkg>

npm - tag

Tags the specified version of the package with the specified tag, or the -- tag config if not specified. Syntax : - npm tag <name>@<version> [<tag>]

npm - test

This runs a package's "test" script, if one was provided.
To run tests as a condition of installation, set the npat config to true.
Syntax : - npm test [-- <args>]
npm tst [-- <args>]

npm - update

This command will update all the packages listed to the latest version (specified by the tag config).
Syntax : - npm update [-g] [<name> [<name> ...]]

npm - version

Run this in a package directory to bump the version and write the new data back to the package.json file.
Syntax : - npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease]

npm - view

This command shows data about a package and prints it to the stream referenced by the outfd config, which defaults to stdout.
Syntax : - npm view [@<scope>/]<name>[@<version>] [<field>[.<subfield>]...] npm v [@<scope>/]<name>[@<version>] [<field>[.<subfield>]...]

npm - whoami

Print the username config to standard output.
Syntax : - npm whoami



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/slides/node-package-manager-commands-slides-presentation.php