当前位置:网站首页>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>
边栏推荐
- P2648 make money
- Comprehensive ability evaluation system
- 电脑钉钉怎么调整声音
- Global and Chinese markets for endoscopic drying storage cabinets 2022-2028: Research Report on technology, participants, trends, market size and share
- 729. 我的日程安排表 I(set or 动态开点线段树)
- [adjustable delay network] development of FPGA based adjustable delay network system Verilog
- tengine 内核参数
- Introduction to hashtable
- Le compte racine de la base de données MySQL ne peut pas se connecter à distance à la solution
- Fedora/REHL 安装 semanage
猜你喜欢
[Zhao Yuqiang] deploy kubernetes cluster with binary package
CertBot 更新证书失败解决
Record an excel xxE vulnerability
Lombok principle and the pit of ⽤ @data and @builder at the same time
In depth MySQL transactions, stored procedures and triggers
VNCTF2022 WriteUp
MLAPI系列 - 04 - 网络变量和网络序列化【网络同步】
About some basic DP -- those things about coins (the basic introduction of DP)
Certbot failed to update certificate solution
JVM garbage collector concept
随机推荐
VNCTF2022 WriteUp
POI add border
10个 Istio 流量管理 最常用的例子,你知道几个?
绑定在游戏对象上的脚本的执行顺序
Web components series (VII) -- life cycle of custom components
食品行业仓储条码管理系统解决方案
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
TCP/IP协议里面的网关地址和ip地址有什么区别?
C. The third problem
解决“C2001:常量中有换行符“编译问题
[leetcode question brushing day 33] 1189 The maximum number of "balloons", 201. The number range is bitwise AND
Comprehensive ability evaluation system
2327. Number of people who know secrets (recursive)
During pycharm debugging, the view is read only and pause the process to use the command line appear on the console input
10 exemples les plus courants de gestion du trafic istio, que savez - vous?
MySQL transaction isolation level
729. My schedule I (set or dynamic open point segment tree)
How does technology have the ability to solve problems perfectly
hashlimit速率控制