当前位置:网站首页>Explain four interesting NPM usages with charts
Explain four interesting NPM usages with charts
2022-07-26 13:48:00 【Ink fragrance^_^】
1、 npm add to === npm install
If you try to npm Search in official documents npm add command , You will find that this command doesn't seem to exist at all , Here's the picture :

But we can use this command on the terminal :
$ npm add lodashactually ,npm add yes npm install One of the aliases of . So when we use npm add when , Exactly equivalent to npm perform npm install !
Again ,npm i It's also npm install Another name for .

2、npm instal ? No problem
Careful readers may have found out , The installation in the subtitle above is a misspelling of this word . But it does work .
$ npm instal lodashActually, this is npm 8.x A new feature of version , It's called fault tolerant design . If the user accidentally misspells a word ,NPM It still works .
So in 8.x In the version ,npm install Got it 9 An alias , Namely :
in, ins, inst, insta, instal, isnt, isnta, isntal, isntall
3、 You can perform some additional actions before and after each script execution
Suppose we have a name greet Script for :

Now we want to :
stay greet Output something before execution : stay greet Before doing something ;
stay greet Output something after execution : stay greet Then do something .
So what should we do ?
We can add a pregreet Script and a postgreet Script , This is a NPM The mechanism of , With pre and post The first script is considered a special script .


This mechanism is often used in the automatic deployment of projects .
4、 Use npm link Install some terminal commands
If you are in the project package.json In the definition of bin Property and point it to the executable script file .
for example :
package.json :
{"name": "npm-test","bin": {"hello-npm-1": "./build/hello.sh"}}
hello.sh :
echo "hello npm"And then we can use it npm link Install it to shell In command :

In the figure :

This is how to install create-react-app and vue-cli The way .
边栏推荐
- Tianjin emergency response Bureau and central enterprises in Tianjin signed an agreement to deepen the construction of emergency linkage mechanism
- 【OAuth2】八、OAuth2登录的配置逻辑-OAuth2LoginConfigurer和OAuth2ClientConfigurer
- Zhou Wei: look for non consensual investment opportunities to accompany the founding team that delays satisfaction
- 万字长文,浅谈企业数字化建模蓝图
- Pass parameters to the routing component
- redis学习笔记
- 二叉树的层序遍历(C语言实现)
- 周伟:寻找非共识性投资机会,陪伴延迟满足的创始团队
- Activity. Onstop() delay 10 seconds? Wonderful investigation process
- MySQL's practice of SQL analysis and optimization from the index principle
猜你喜欢

天翼云Web应用防火墙(边缘云版)支持检测和拦截Apache Spark shell命令注入漏洞
![[collection of topics that C language learners must know 1] consolidate the foundation and steadily improve](/img/95/bec94176cadfac112585df259156c9.png)
[collection of topics that C language learners must know 1] consolidate the foundation and steadily improve

Use the requests library to crawl web pages

MySQL's practice of SQL analysis and optimization from the index principle

【C语言学习者必会的题目集锦1】巩固基础,稳步提高

The serialization class in unity is in JSON format

Solve the problem that the remote host cannot connect to the MySQL database

Videojs to canvas pause, play, switch video

Implementation of SAP ABAP daemon

MVVM architecture encapsulation of kotlin series (kotlin+mvvm)
随机推荐
Native JS get transform value x y z and rotate rotation angle
华为机考 ~ 偏移量实现字符串加密
Mobile dual finger scaling event (native), e.originalevent.touches
Unicode file parsing methods and existing problems
Pytoch learning notes (III) use, modification, training (cpu/gpu) and verification of the model
Ros2 learning (1) introduction to ros2
Docker integrates the redis sentinel mode (one master, two slave and three sentinels)
Force deduction ----- the number of words in the string
Propagation of transactions
Photoshop (cc2020) unfinished
重押海外:阿里、京东、顺丰再拼“内力”
时间复杂度和空间复杂度
421. Maximum XOR value of two numbers in the array
向路由组件传递参数
421. 数组中两个数的最大异或值
Sword finger offer (VII): Fibonacci sequence
【开源之美】nanomsg(2) :req/rep 模式
Docker swarm cluster builds highly available MySQL active and standby
How to write the introduction of GIS method journals and papers?
Subscription and publication of messages