Home >Web Front-end >Front-end Q&A >What are the differences between node's installation modes?

What are the differences between node's installation modes?

WBOY
WBOYOriginal
2022-04-19 18:12:031773browse

Difference: 1. Local installation downloads the module to the directory where the current command line is located, while global installation downloads and installs the module into the global directory, that is, under "node_modules" under the Node installation directory; 2. Local installation Installation can be introduced directly through require(), but global installation cannot use require().

What are the differences between node's installation modes?

The operating environment of this tutorial: windows10 system, nodejs version 12.19.0, Dell G3 computer.

What are the differences between the installation modes of node

1. Different installation locations:

Local installation:

npm install moduleName

then Is to download the module to the directory where the current command line is located.

Global installation:

npm install moduleName -g

The module will be downloaded and installed in the global directory, that is, under node_modules in the Node installation directory

2. The calling method is different:

In the code, local installation can be introduced directly through require(); var moduleName = require('moduleName');

Global installation is for command line (command line), such as grunt, the global installation method cannot use require to call the package;

Note:

You can set the installation mode by using npm set global=true/false , npm get global can view the currently used installation mode.

Recommended learning: "nodejs video tutorial"

The above is the detailed content of What are the differences between node's installation modes?. 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