Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the differences between the installation modes of node

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

What are the differences between the installation modes of node? most people do not understand the knowledge points of this article, so the editor summarizes the following contents, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "what are the differences between the installation modes of node?"

Differences: 1, the local installation is to download the module to the current command line directory, while the global installation downloads the module to the global directory, that is, under the "node_modules" under the Node installation directory; 2, the local installation can be introduced directly through require (), while the global installation cannot be require ().

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

What is the difference between the installation modes of node

1. Different installation locations:

Local installation:

Npm install moduleName

The module is downloaded to the current command line directory.

Global installation:

Npm install moduleName-g

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

2. The calling method is different:

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

Global installation is for command line (command line) use, such as grunt. There is no way to call the package with require in the global installation.

Note:

You can set the installation mode by using npm set global=true/false, and npm get global can see which installation mode is currently in use.

The above is about the content of this article on "what are the differences between the installation modes of node". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report