当前位置:网站首页>NPM command -- install dependent packages -- Usage / explanation
NPM command -- install dependent packages -- Usage / explanation
2022-07-06 04:19:00 【It blade out of sheath】
Original website :npm command -- Install dependency packages -- usage / Detailed explanation _IT A blog with a sharp blade -CSDN Blog
brief introduction
In this paper, npm How to install dependent packages .
usage
command | effect | detailed |
npm install <pkg> // A synonym for :i, isntall, add | install pkg package | To download pkg, Then download pkg Of packages.json Inside dependencies、devDependencies Dependencies of, etc . If there is... In the path where the command is executed packages.json, Then add this dependency to its dependencies. |
npm install pkg1 pkg2 | Install multiple packages | |
npm install git://github.com/package/path.git | from git Download and install | |
npm install [email protected] | Specified version number | Install the latest version by default , If you want to install a specific version of the module , You can add... After the module name @ And version number . |
Parameters
Parameters | explain | detailed |
-f/--force | Mandatory installation . Reinstall whether it has been installed or not . | Before the installation ,npm install Will check node_modules Whether the specified module already exists in the directory . If there is , It's not going to be reinstalled , Even if there is a new version of the remote repository , So it is with . |
-g/--global | Global installation | Please see below :“ Local installation / Global installation ” |
-P/--save-prod -S/--save( The old version ) | Add the module name to the production phase dependency : dependencies | Add module name to packages.json Of documents dependencies term . If there is... In the path where the command is executed packages.json, Not specifying this parameter will also add this dependency to its dependencies. |
-D/--save-dev | Add the module name to the development phase dependency :devDependencies | Add module name to packages.json Of documents devDependencies term . |
-O|--save-optional | Add module name to optionalDependencies | Add module name to packages.json Of documents optionalDependencies term . // I don't know the function of this at present |
-E/--save-exact | Precisely install the specified version of the module | With this option dependencies Field in front of each module version number ^ Be missing . |
--dry-run | Just run the command , It's not actually installed |
Local installation / Global installation
If you want to have local installation and global installation , You need to install it or use it in two places npm link.
Local installation
command
npm install <Module Name>
Detailed explanation
- Will put the installation package in ./node_modules Next ( function npm The directory where the command is located ), without node_modules Catalog , Will be executed in the current npm Command directory to generate node_modules Catalog .
- Can pass require() To introduce locally installed packages .
Global installation
command
npm install <package> -g
Detailed explanation
- It is placed in the user directory by default . Can pass npm get prefix Check the installation location
Default location linux: /usr/local windows: C:\Users\xxx\AppData\Roaming\npm - It can be used directly in the command line .
The method of installing to the specified location during global installation
Law 1: Modify the configuration
establish node_cache And node_global Folder , Then set the Global installation location
npm set cache D:\ST\nodejs\node_cache
npm set prefix D:\ST\nodejs\node_globalLaw 2: Specify the location during installation
npm install --prefix ./install/here <package>
边栏推荐
- Jd.com 2: how to prevent oversold in the deduction process of commodity inventory?
- C. The third problem
- flink sql 能同时读多个topic吗。with里怎么写
- HotSpot VM
- Python book learning notes - Chapter 09 section 01 create and use classes
- Recommendation system (IX) PNN model (product based neural networks)
- Class A, B, C networks and subnet masks in IPv4
- 拉格朗日插值法
- 10 exemples les plus courants de gestion du trafic istio, que savez - vous?
- 记一次excel XXE漏洞
猜你喜欢

Practical development of member management applet 06 introduction to life cycle function and user-defined method

Class A, B, C networks and subnet masks in IPv4

满足多元需求:捷码打造3大一站式开发套餐,助力高效开发

1291_ Add timestamp function in xshell log

Web components series (VII) -- life cycle of custom components

解决“C2001:常量中有换行符“编译问题

View 工作流程

During pycharm debugging, the view is read only and pause the process to use the command line appear on the console input

Le compte racine de la base de données MySQL ne peut pas se connecter à distance à la solution

R note prophet
随机推荐
Global and Chinese markets for fire resistant conveyor belts 2022-2028: Research Report on technology, participants, trends, market size and share
Certbot failed to update certificate solution
Lombok principle and the pit of ⽤ @data and @builder at the same time
满足多元需求:捷码打造3大一站式开发套餐,助力高效开发
MLAPI系列 - 04 - 网络变量和网络序列化【网络同步】
[face recognition series] | realize automatic makeup
1291_ Add timestamp function in xshell log
. Net interprocess communication
Global and Chinese market of plasma separator 2022-2028: Research Report on technology, participants, trends, market size and share
[Zhao Yuqiang] deploy kubernetes cluster with binary package
P2648 make money
Mysql数据库慢sql抓取与分析
Yyds dry goods inventory web components series (VII) -- life cycle of custom components
C. The third problem
Recommendation | recommendation of 9 psychotherapy books
Le compte racine de la base de données MySQL ne peut pas se connecter à distance à la solution
牛顿插值法
P2022 interesting numbers (binary & digit DP)
[PSO] Based on PSO particle swarm optimization, matlab simulation of the calculation of the lowest transportation cost of goods at material points, including transportation costs, agent conversion cos
颠覆你的认知?get和post请求的本质