Common commands of Nodejs npm and Common commands of nodejsnpm
Npm is a node package management and distribution tool and has become an unofficial standard for releasing node modules (packages. With npm, you can quickly find the packages to be used by specific services, download, install and manage installed packages.
1. npm install moduleNames: install the Node Module
After the installation is complete, a node_modules directory is generated, under which each node module is installed.
Node installation is divided into global mode and local mode.
Generally, the package runs in local mode and is installed in the local node_modules directory of your application code.
In global mode, the Node package is installed under node_modules under the Node installation directory.
The global installation command is npminstall −gmodulename. We learned to use npminstall −gmodulename. We know that npm set global = true is used to set the installation mode, and $ npm get global can view the current installation mode.
Example:
Npm install express
By default, the latest version of express is installed, or you can install a specified version by adding a version later, such as the npm install express@3.0.6
Npm install <name>-g
Install the package in the global environment
However, in the Code, there is no way to call the global installation package directly by using require. Global installation is for the command line. It is like after vmarket is installed globally, you can directly run vm commands in the command line.
Npm install <name> -- save
At the same time of installation, write information to the project path in package. json. If there is a package. json file, you can directly use the npm install method according
Dependencies configure and install all the dependent packages. When the code is submitted to github, you do not need to submit the node_modules folder.
2. npm view moduleNames: view the package. json folder of the node Module
Note: To view the content of a label in the package. json folder, you can use $ npm view moduleName labelName
3. npm list: view the installed node packages in the current directory
Note: The Node module search starts from the current directory where the code is executed. The search result depends on the content in the node_modules directory currently in use. $ Npm list parseable = true: All node packages currently installed can be displayed in a directory.
4. npm help: View help commands
5. npm view moudleName dependencies: view the package dependency
6. npm view moduleName repository. url: view the package source file address
7. npm view moduleName engines: view the Node version on which the package depends
8. npm help folders: view all folders used by npm
9. npm rebuild moduleName: used to change the package content and re-build it.
10. npm outdated: Check whether the package is out of date. This command will list all outdated packages and update the packages in time.
11. npm update moduleName: update node Module
12. npm uninstall moudleName: uninstall the node Module
13. an npm package contains a package. json folder. package. json describes the structure of this folder. The method for accessing the npm json folder is as follows:
$ Npm help json
This command opens a web page by default. If the default program is changed, it may not be opened in the form of a Web page.
14. When releasing an npm package, check whether a package name already exists.
$ Npm search packageName
15. npm init: guides you to create a package. json file, including the name, version, and author information.
16. npm root: Check the installation path of the current package.
Npm root-g: Check the installation path of the global package
17. npm-v: view the npm installation version.
The above is a full description of the frequently-used Nodejs npm commands introduced by xiaobian. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!