当前位置:网站首页>NPM and yarn use (official website, installation, command line, uploading your own package, detailed explanation of package version number, updating and uninstalling package, viewing all versions, equ
NPM and yarn use (official website, installation, command line, uploading your own package, detailed explanation of package version number, updating and uninstalling package, viewing all versions, equ
2022-07-28 08:55:00 【YF-SOD】
Catalog
npm i [email protected] Version number
install git The package released on
npm config set registry https://registry.npm.taobao.org
yarn add [email protected] Version number
yarn upgrade [email protected] Version number
npm
NodeJS Package management and distribution tools .
Official website
npm install packageName
Install dependency packages .
--S(--save): default , Used to write package.json Production environment document .
-D(--save-dev): Used to write package.json Development environment file .
-g(-global): Global installation , Not -g All are locally installed . Here is -g The installation directory
![]()
mac The global installation directory is /User/ Your username /.nvm/versions/node/nvm edition /bin
window The global installation directory is C:\Users\ Your username \AppData\Roaming\npm\node_modules
Partial installation passed node_modulet/.bin/packageName Run non -g Downloaded module commands .
npm i [email protected] Version number
Automatically install the specified version of the package , Except for the specified version number , Other version numbers are automatically the latest .
Version number includes : The major version number . Sub version number . Patch number
package.json in ^ It refers to locking the major version number ,~ It refers to locking the major version number and minor version number , Empty finger locks the entire version number ,* Refer to the latest version .
install git The package released on
# This is suitable for the installation of... Within the company git The project on the server
npm install git+https://[email protected]:lurongtao/gp-project.git
# Or with ssh The way
npm install git+ssh://[email protected]:lurongtao/gp-project.git
The red box in the following figure is through git Installation of the package

npm ci
according to package-lock.json(npm i Post generated files , Used to lock versions and record dependencies ) File installation depends on . comparison npm i Speed increased significantly . Also support --production Parameters .
Be careful ( contrast npm i)
- npm ci Cannot be used to install a single dependency , Can only be used to install dependencies for the entire project
- npm ci Will detect if
node_modulesAlready exist , Delete first and then install - Will not update
package.jsonorpackage-lock.jsonfile , The whole installation process is locked . package-lock.json、npm-shrinkwrap.jsonIf the file does not exist, an error will be reported- lock And
package.jsonThe version in does not match ,npm ci Direct error reporting interrupt , Instead of updating lock file .
Recommended :npm ci --cache .npm --quiet --no-progress close log And progress , It can speed up the download .
npm outdated
Show package.json The other version bits under the locked version bit in are not the latest packages .

npm update
take package.json Other version bits under the locked version bit of the package become the latest .

npm init -y
Generate package.json Module profile .
At this point through npm run dev The command is equivalent to entering ./node_modules/.bin/gulp -v.
Note that the red box below can be removed , function npm run dev Command will automatically go to the global to find the corresponding file , If not, you will go to the current path node_modules Search for .

stay scripts The script written on , The environment to run from the command line is node Environment .
npm list
Check the versions of all installation packages and dependent installation packages .

npm list | grep packageName
View the version of the specified installation package and the dependent installation package
npm install --production
Install only package.json Production environment package in .
npm view packagename versions
View all versions of the specified package
npm cache clean --force
eliminate npm cache ( Use when you can't download after downloading errors )
npm config get registry
Get the remote warehouse Path .
npm config set registry https://registry.npm.taobao.org
Set the remote warehouse address to Taobao image path , The default remote warehouse address is http://registry.npmjs.org.
module.exports = Variable name
You can also directly exports Mount variables on ,exports by module.exports References on ( You can't give it directly to exports assignment )
require('./ route ') You cannot write the beginning of the file name directly , What is introduced is export References to .
npm install express-generator -g Command to install
express -h Option to list all available command line options
express -e Directly generate the server-side project
Upload your own package
land npm Official website , Password of registered account , Execute the following command . Note that the uploaded package should have packgage.json file .package.json in name For the uploaded package name ,version Version number ,description by readme Described in the .

npm adduser
Landing user . Note that the remote image warehouse should be http://registry.npmjs.org. If not, you need to reset the original address and log in again .
npm publish
Upload your own package .
yarn
Package management and distribution tools . Only partial and npm The command line has different commands .
Chinese official website
install
install | Yarn Chinese document
Command line
yarn add [email protected] Version number
Install dependency packages .
--dev(-D): Development environment dependency , Used to write package.json Development environment file .
--peer(-P): Equally dependent on , Or peer dependence ( When multiple packages depend on 1 A bag , Use when you need to unify the version of this package ).
--optional(-O): Optional dependency , If there are some dependent packages, even if the installation fails , Install alternate packages to keep the project running . You can use optionalDependencies. Be careful packageName in optionalDependencies Will be covered dependencies Dependency package with the same name in , So don't write in both places .
yarn|yarn install
Install all dependent packages .
yarn upgrade [email protected] Version number
Upgrade the dependent package to the specified version .
yarn remove packageName
Uninstall the specified dependent package .
yarn dlx mocha --version
need yarn2 Version of , amount to npx mocha --version. Used to call modules installed inside the project .
nvm、nrm、npx Use ( install 、 Basic commands 、 Parameters 、curl、wget)_YF-SOD The blog of -CSDN Blog
边栏推荐
- Machine learning how to achieve epidemic visualization -- epidemic data analysis and prediction practice
- Network interface network crystal head RJ45, Poe interface definition line sequence
- 微服务架构 Sentinel 的服务限流及熔断
- ciou损失
- Gb/t 41479-2022 information security technology network data processing security requirements map overview
- In addition to exporting the incremental data captured by Oracle golden gate to Oracle, where can it be exported? Can be similar
- Competition: diabetes genetic risk detection challenge (iFLYTEK)
- Export SQL server query results to excel table
- Sparksql and flinksql create and link table records
- 我来教你如何组装一个注册中心?
猜你喜欢

Two dimensional array and operation

Div tags and span Tags

Competition: diabetes genetic risk detection challenge (iFLYTEK)

ciou损失

思迈特软件Smartbi完成C轮融资,推动国产BI加速进入智能化时代

Huid learning 7: Hudi and Flink integration
![[soft test software evaluator] 2013 comprehensive knowledge over the years](/img/c5/183acabd7015a5e515b7d83c127b2c.jpg)
[soft test software evaluator] 2013 comprehensive knowledge over the years

Analysis and recurrence of network security vulnerabilities

1w5 words to introduce those technical solutions of distributed system in detail

Bash shell interaction free
随机推荐
Post it notes -- 45 {packaging of the uniapp component picker, for data transmission and processing -- Based on the from custom packaging that will be released later}
MySQL how to add users and set permissions?
竞赛:糖尿病遗传风险检测挑战赛(科大讯飞)
Redis 基本知识,快来回顾一下
PostgreSQL: cannot change the type of column used by a view or rule
Detailed explanation of switch link aggregation [Huawei ENSP]
Div tags and span Tags
After summarizing more than 800 kubectl aliases, I'm no longer afraid that I can't remember commands!
Quickly build a gateway service, dynamic routing and authentication process, and watch the second meeting (including the flow chart)
Recruiting talents, gbase high-end talent recruitment in progress
Two dimensional array and operation
[mindspire YiDianTong robot-01] you may have seen many Knowledge Q & A robots, but this is a little different
Blog building 7: Hugo
Why setting application.targetframerate doesn't work
Round C financing has been completed! Smart software leads domestic Bi ecological empowerment, and products and services are a step forward
XMIND Zen installation tutorial
Will sqlserver CDC 2.2 generate table locks when extracting large tables from the source
Solution: indexerror: index 13 is out of bounds for dimension 0 with size 13
第2章-2 计算分段函数[1]
Top all major platforms, 22 versions of interview core knowledge analysis notes, strong on the list