当前位置:网站首页>Use of NPM
Use of NPM
2022-07-27 07:57:00 【txq231254】
One 、 install npm
npm yes Node.js The default package management system
Installation completed node after , It will be installed by default npm
npm It's also based on Node.js Developed software
download Node:http://nodejs.cn
1.npm Setting and viewing of image
When setting up the environment, you should pass through such as ” The next code will npm Set to Taobao image
npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global
Set current address ( Set as default address )
npm config set registry https://reistr.npmjs.org/
View the configuration results of the image
npm config get registry
Use nrm Tool switch Taobao source
npx nrm use taobao
If you need to switch back to the official source later, you can use
npx nrm use npm
You can use Taobao customized cnpm(gzip Compression support ) The command line tool replaces the default npm:
npm config get disturl
s npm install -g cnpm -rgistrttstp/istry.pm.taobao.org
2.NPM Use
npm -V By looking at the version , see npm Is the installation successful
npm install <Module Name>
Use npm Command install module
npm install <Module Name> -g You can use global directly on the command line
npm list -g View all globally installed modules
npm list vue View the version number of a module
npm -g install [email protected] (@ Followed by the version number ) So we can update npm edition
npm install -save moduleName
# -save stay package Of documents dependencies Node write dependency .
npm install -save-dev moduleName # -save-dev stay package Of documents devDependencies Node write dependency
dependencies: Run time dependencies , After the release of , That is, the modules that need to be used in the production environment
devDependencies: Development dependencies . The modules inside are used for development , You can't use it when publishing, such as in the project gulp, Compress Css Module . These modules are not needed after our project is deployed
3.Package.json Attribute specification
name - Package name .
version - Version number of the package .
description - Package description .
homepage - Bao's official website url.
author - The name of the author of the bag .
contributors - Name of other contributors to the package .
dependencies - Dependency package list . If the dependency package is not installed , npm Will automatically install the dependency package in node_ module Under the table of contents .
repository - The type of place where the package code is stored , It can be git or svn, git Can be found in Github On .
main - main Field specifies the main entry file of the program ,require(' moduleName') It will load the file . The default value of this field is... Under the module root directory index.js.
keywords - keyword
4.yarn Installation and use
4,1Yarn What is it? ?
"Yarn By Facebook、Google、 Exponent and Tilde Joint launch of a new JS Package management tools , As the official document says ,Yarn To make up for npm Some of the defects of . because NPM5 The following questions will appear :
npm install It's very slow . In particular, it will take half a day for new projects to be pulled down , Delete node_ modules, again install It's still the case . The same project , When multiple people develop , Due to inconsistent installed versions bug
Official website :www.yarnpkg.com
4.2yarn Installation
download node.js, Use npm install
npm install -g yarn
View version : yarn --version
install node.js, download yarn Installation procedure :
Provide a .msi file , At run time, you will be guided to Windows. Installation on Yarn
Yarn Taobao source installation , Copy and paste the following lines to the black window to run
yarn config set registry https://registry.npm.taobao.org -g
yarn config set sass_binary_ site http://cdn.npm.taobao.org/dist/node-sass -g
4yarn Basic use of
yarn init
// The initialization project is the same as npm init, After executing the input information , Will generate package.json file
yarn install
// install package.json All the bags in the bag , And save the package and all its dependencies into yarn.lock
yarn install -lat
// install - A single package - - edition
yarn install --force
// Force all packages to be downloaded again
yarn install --production
// Install only dependencies Bag in
yarn install --no-lockfile
// Do not read or generate arn.lock
yarn install --pure-lockfile
// No generation yarn.lock
yarn add [package]
// Add a dependency package to the current project , Will automatically update to package.json and yarn.lock In file
yarn add [package]@[version] // Install the specified version , This refers to the main version , If you need to be accurate to a small version , Use -E Parameters
yarn add [package]@[tag] // Install a tag ( such as beta,next perhaps latest)
yarn add --dev/-D
// Add to devDependencies
yarn add -.-.......... /. Add to peerDependencies
yarn add --optional/-O
// Add to optionalDependencies
Yarn The advantages of
- Fast
- The installation version is unified
- More concise output
- Multi registration source processing .
- Better semantics
边栏推荐
- 剑指 Offer 58 - I. 翻转单词顺序
- Kalibr calibration realsensed435i -- multi camera calibration
- Redisson 3.17.5 发布,官方推荐的 Redis 客户端
- Shell awk related exercises
- Happy holidays, everyone
- 帮个忙呗~不关注不登录,不到一分钟的一个问卷
- 物来顺应,未来不迎,当时不杂,既过不恋
- Internet of things industrial UART serial port to WiFi to wired network port to Ethernet Gateway WiFi module selection
- Synchronized lock
- Showdoc vulnerability learning - cnvd-2020-26585 (arbitrary file upload)
猜你喜欢

Lua迭代器

帮个忙呗~不关注不登录,不到一分钟的一个问卷
![[stonedb class] introductory lesson 1: popular science of database knowledge](/img/ec/4e3c0b91ac2ee164595c2891b23dfb.jpg)
[stonedb class] introductory lesson 1: popular science of database knowledge

【万字长文】吃透负载均衡,和阿里大牛的技术面谈

什么是真正的HTAP?(一)背景篇

杂谈:手里有竿儿,肩上有网,至于背篓里有多少鱼真的重要吗?

Combined use of C WinForm form form event and delegate

Demo:pa30 Bank Country Code default CN enhancement

【小程序】如何获取微信小程序代码上传密钥?

How to obtain the cash flow data of advertising services to help analyze the advertising effect?
随机推荐
How to analyze and locate problems in 60 seconds?
Combined use of C WinForm form form event and delegate
Confluence vulnerability learning - cve-2021-26084/85, cve-2022-26134 vulnerability recurrence
C语言:随机生成数+希尔排序
浅谈数据安全
SETTA 2020 国际学术会议即将召开,欢迎大家参加!
Practical new drug R & D project management platform
[flight control development foundation tutorial 4] crazy shell · open source formation UAV - serial port (optical flow data acquisition)
如何更新pip3?和Running pip as the ‘root‘ user can result in broken permissions and conflicting behaviour
Redison 3.17.5 release, officially recommended redis client
linux中mysql表名区不区分大小写
增强:BTE流程简介
Leetcode54. 螺旋矩阵
C language: random number + Hill sort
API 版本控制【 Eolink 翻译】
Regular and sed exercises
Framework of electronic mass production project -- basic idea
Interview reply V
什么是真正的HTAP?(一)背景篇
Lua stateful iterator