Home >Web Front-end >Front-end Q&A >What is npm in node environment

What is npm in node environment

WBOY
WBOYOriginal
2022-07-06 10:57:082404browse

npm in the node environment is the default package management and distribution tool; the full name of npm is "Node Package Manager", which has become an unofficial standard for publishing node modules. npm allows users to download others from the NPM server Write third-party packages for local use, or allow users to upload their own packages or command line programs to the NPM server for others to use.

What is npm in node environment

The operating environment of this article: Windows 10 system, nodejs version 16, Dell G3 computer.

What is npm in the node environment

npm is the default package manager for the JavaScript runtime environment Node.js.

NPM’s full name is Node Package Manager, which is a NodeJS package management and distribution tool that has become an unofficial standard for publishing Node modules (packages).

npm is a package management tool installed along with Nodejs. It can solve many problems in Nodejs code deployment. Common usage scenarios include the following:

  • Allow users Download third-party packages written by others from the NPM server and use them locally.

  • Allows users to download and install command line programs written by others from the NPM server for local use.

  • Allows users to upload packages or command line programs they write to the NPM server for others to use.

Since the new version of nodejs has integrated npm, npm has also been installed before. You can also test whether the installation is successful by entering "npm -v". The command is as follows. If the version prompt appears, it means the installation is successful:

$ npm -v
2.3.0

If you are installing an old version of npm, you can easily upgrade it through the npm command. The command is as follows:

$ sudo npm install npm -g
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
npm@2.14.2 /usr/local/lib/node_modules/npm

If it is Window The system can use the following command: npm install npm -g

Global installation and local installation

npm package installation is divided into local installation (local) and global installation (global) ). Judging from the command line, the difference is only whether there is -g. For example,

npm install express          # 本地安装
npm install express -g   # 全局安装

If the following error occurs: npm err! Error: connect ECONNREFUSED 127.0.0.1:8087

The solution is: $ npm config set proxy null

Local installation

  • ##Place the installation package under ./node_modules (run the npm command directory), if there is no node_modules directory, the node_modules directory will be generated in the directory where the npm command is currently executed.

  • You can introduce locally installed packages through require().

Global installation

  • Place the installation package under /usr/local or the installation directory of your node.

  • can be used directly in the command line.

If you want to have the functionality of both, you need to install it in two places or use npm link.

Recommended learning: "

nodejs video tutorial"

The above is the detailed content of What is npm in node environment. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What does node-sass do?Next article:What does node-sass do?