当前位置:网站首页>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>
边栏推荐
- coreldraw2022新版本新功能介绍cdr2022
- Use js to complete an LRU cache
- Record an excel xxE vulnerability
- DM8 archive log file manual switching
- lora网关以太网传输
- 捷码赋能案例:专业培训、技术支撑,多措并举推动毕业生搭建智慧校园毕设系统
- Figure application details
- Codeforces Round #770 (Div. 2) B. Fortune Telling
- How does technology have the ability to solve problems perfectly
- 我想问一下 按照现在mysql-cdc的设计,全量阶段,如果某一个chunk的binlog回填阶段,
猜你喜欢
VNCTF2022 WriteUp
Stable Huawei micro certification, stable Huawei cloud database service practice
Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage
When debugging after pycharm remote server is connected, trying to add breakpoint to file that does not exist: /data appears_ sda/d:/segmentation
题解:《单词覆盖还原》、《最长连号》、《小玉买文具》、《小玉家的电费》
Viewing and verifying backup sets using dmrman
Guitar Pro 8.0最详细全面的更新内容及全部功能介绍
Solve the compilation problem of "c2001: line breaks in constants"
During pycharm debugging, the view is read only and pause the process to use the command line appear on the console input
What is the difference between gateway address and IP address in tcp/ip protocol?
随机推荐
cdc 能全量拉去oracle 表嘛
Query the number and size of records in each table in MySQL database
Implementation of knowledge consolidation source code 2: TCP server receives and processes half packets and sticky packets
Global and Chinese market of rubber wheel wedges 2022-2028: Research Report on technology, participants, trends, market size and share
[adjustable delay network] development of FPGA based adjustable delay network system Verilog
10 exemples les plus courants de gestion du trafic istio, que savez - vous?
[disassembly] a visual air fryer. By the way, analyze the internal circuit
[Zhao Yuqiang] deploy kubernetes cluster with binary package
MySQL learning record 13 database connection pool, pooling technology, DBCP, c3p0
VNCTF2022 WriteUp
Understanding of processes, threads, coroutines, synchronization, asynchrony, blocking, non blocking, concurrency, parallelism, and serialization
About some basic DP -- those things about coins (the basic introduction of DP)
Mysql database storage engine
Fundamentals of SQL database operation
Codeforces Round #770 (Div. 2) B. Fortune Telling
Recommendation system (IX) PNN model (product based neural networks)
The global and Chinese market of negative pressure wound therapy unit (npwtu) 2022-2028: Research Report on technology, participants, trends, market size and share
Basic knowledge of binary tree, BFC, DFS
R note prophet
Fedora/rehl installation semanage