当前位置:网站首页>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>
边栏推荐
- [face recognition series] | realize automatic makeup
- Overturn your cognition? The nature of get and post requests
- Leetcode32 longest valid bracket (dynamic programming difficult problem)
- QML和QWidget混合开发(初探)
- Mysql database storage engine
- P2102 地砖铺设(dfs&贪心)
- P3500 [POI2010]TES-Intelligence Test(二分&离线)
- User datagram protocol UDP
- How many of the 10 most common examples of istio traffic management do you know?
- 2328. 网格图中递增路径的数目(记忆化搜索)
猜你喜欢

DM8 archive log file manual switching

捷码赋能案例:专业培训、技术支撑,多措并举推动毕业生搭建智慧校园毕设系统

Fedora/REHL 安装 semanage

Patent | subject classification method based on graph convolution neural network fusion of multiple human brain maps

Lombok principle and the pit of ⽤ @data and @builder at the same time

关于进程、线程、协程、同步、异步、阻塞、非阻塞、并发、并行、串行的理解
![[tomato assistant installation]](/img/06/672a616d4fc2a43b83054eb1057628.jpg)
[tomato assistant installation]

图应用详解

JVM garbage collector concept

解决“C2001:常量中有换行符“编译问题
随机推荐
牛顿插值法
User datagram protocol UDP
图应用详解
HotSpot VM
Lora gateway Ethernet transmission
Explain in simple terms node template parsing error escape is not a function
【HBZ分享】ArrayList的增删慢查询快的原因
E. Best Pair
Several important classes in unity
How to solve the problem of slow downloading from foreign NPM official servers—— Teach you two ways to switch to Taobao NPM image server
Certbot failed to update certificate solution
1291_ Add timestamp function in xshell log
MySql数据库root账户无法远程登陆解决办法
Global and Chinese market of plasma separator 2022-2028: Research Report on technology, participants, trends, market size and share
npm命令--安装依赖包--用法/详解
Global and Chinese market of rubber wheel wedges 2022-2028: Research Report on technology, participants, trends, market size and share
729. My schedule I (set or dynamic open point segment tree)
脚本生命周期
How does technology have the ability to solve problems perfectly
. Net interprocess communication