当前位置:网站首页>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
边栏推荐
- The first open source MySQL native HTAP database in China will be released soon! Look at the three highlights first, limited to the surrounding areas, waiting for you~
- Chromedriver download - self use
- MySQL table name area in Linux is not case sensitive
- Confluence vulnerability learning - cve-2021-26084/85, cve-2022-26134 vulnerability recurrence
- Internet of things industrial UART serial port to WiFi to wired network port to Ethernet Gateway WiFi module selection
- 将对象转换为键值对
- ADC噪声全面分析 -01- ADC噪声的类型以及ADC特性
- glGetUniformLocation,glUniform4f
- C language: random generated number + insertion sort
- Happy holidays, everyone
猜你喜欢

北京五日游记

Enhancement: BTE process introduction

综合案例、

Comprehensive cases

QingChuang technology joined dragon lizard community to build a new ecosystem of intelligent operation and maintenance platform

大家节日快乐哈

Do me a favor ~ don't pay attention, don't log in, a questionnaire in less than a minute

【StoneDB Class】入门第一课:数据库知识科普

Gossip: is rotting meat in the pot to protect students' rights and interests?

存储过程与函数
随机推荐
【pytorch】ResNet18、ResNet20、ResNet34、ResNet50网络结构与实现
Interview reply V
C language: optimized Hill sort
服务器网络测试的方法
SETTA 2020 国际学术会议即将召开,欢迎大家参加!
LeetCode56. 合并区间
JS存取cookie示例
RPC remote procedure call
API 版本控制【 Eolink 翻译】
杂谈:手里有竿儿,肩上有网,至于背篓里有多少鱼真的重要吗?
【小程序】如何获取微信小程序代码上传密钥?
[ten thousand words long article] thoroughly understand load balancing, and have a technical interview with Alibaba Daniel
slf4j如何进行logback配置呢?
Internet of things industrial UART serial port to WiFi to wired network port to Ethernet Gateway WiFi module selection
物联网工业级UART串口转WiFi转有线网口转以太网网关WiFi模块选型
What other methods are available for MySQL index analysis besides explain
大家节日快乐哈
How to obtain the cash flow data of advertising services to help analyze the advertising effect?
Methods of server network testing
Stored procedures and functions