当前位置:网站首页>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_global
Law 2: Specify the location during installation
npm install --prefix ./install/here <package>
边栏推荐
- asp. Core is compatible with both JWT authentication and cookies authentication
- Leetcode32 longest valid bracket (dynamic programming difficult problem)
- lora网关以太网传输
- Guitar Pro 8.0最详细全面的更新内容及全部功能介绍
- HotSpot VM
- VPP性能测试
- PTA tiantisai l1-078 teacher Ji's return (15 points) detailed explanation
- [FPGA tutorial case 11] design and implementation of divider based on vivado core
- Lombok principle and the pit of ⽤ @data and @builder at the same time
- P2022 有趣的数(二分&数位dp)
猜你喜欢
lora网关以太网传输
[Zhao Yuqiang] deploy kubernetes cluster with binary package
Recommendation | recommendation of 9 psychotherapy books
About some basic DP -- those things about coins (the basic introduction of DP)
查询mysql数据库中各表记录数大小
Deep learning framework installation (tensorflow & pytorch & paddlepaddle)
[adjustable delay network] development of FPGA based adjustable delay network system Verilog
Solution of storage bar code management system in food industry
What is the difference between gateway address and IP address in tcp/ip protocol?
DM8 archive log file manual switching
随机推荐
Global and Chinese markets for endoscopic drying storage cabinets 2022-2028: Research Report on technology, participants, trends, market size and share
10個 Istio 流量管理 最常用的例子,你知道幾個?
1291_ Add timestamp function in xshell log
Global and Chinese markets for patent hole oval devices 2022-2028: Research Report on technology, participants, trends, market size and share
Le compte racine de la base de données MySQL ne peut pas se connecter à distance à la solution
How does computer nail adjust sound
HotSpot VM
2327. 知道秘密的人数(递推)
Mlapi series - 04 - network variables and network serialization [network synchronization]
MLAPI系列 - 04 - 网络变量和网络序列化【网络同步】
满足多元需求:捷码打造3大一站式开发套餐,助力高效开发
DM8 archive log file manual switching
Stable Huawei micro certification, stable Huawei cloud database service practice
[Zhao Yuqiang] deploy kubernetes cluster with binary package
MySql数据库root账户无法远程登陆解决办法
Jd.com 2: how to prevent oversold in the deduction process of commodity inventory?
CertBot 更新证书失败解决
About some basic DP -- those things about coins (the basic introduction of DP)
VPP性能测试
[disassembly] a visual air fryer. By the way, analyze the internal circuit