当前位置:网站首页>How to publish your own NPM package
How to publish your own NPM package
2022-07-25 04:48:00 【Shadow wind Mo】
Preparation
- node Environmental Science , Please go to the official website to download
- npm account number , Please go to this link https://www.npmjs.com/signup register
Create project
perform npm init -y Initialize project 
package.json file :
{
"name": "demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"bin": {
"demo": "index.js"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
index.js file :
Be sure to add this line of code : #!/usr/bin/env node It means that node Running code in environment
#!/usr/bin/env node
console.log(' test !!!');
Local testing :
First step : Publish to global under the current release package directory node_modulesnpm link
Go to test and input yourself directly package.json Inside bin Configuration commands , What I have here demo
The result is :
The second step : The global release package is associated under the local test project directory npm link publishname
Disassociate :
It is necessary to test this movie locally . Mainly, canceling the association relationship can reduce the problems such as dependence on development, failure to install and lag .
- Cancel the association between the test project and the global
In the test project executionnpm unlink publishname - Cancel the association between the publishing project and the global
Execute in the release package projectnpm unlink publishname
Publish online :
There are about two steps :
First step : Login account .
perform npm login , No, npm If you have a local account, you need to execute npm adduser Add local npm account number
If you log in here and report an error , Under execution npm config set registry https://registry.npmjs.org , Must be npmjs Source
The second step : Publish to npmjs Official website
perform npm publish
Be careful : If you report here 403 Error of , No permission to submit to this package warehouse , The reason is that the package name has been occupied , Then modify the name of the definition package , Need to be in package.json File modification name Field changes its name , Its name must be preceded by the function domain name @username/packagename This format is named , And username It can only be the current user , perform npm whoami You can view the current user name
边栏推荐
- [golang from introduction to practice] poker licensing game
- Swagger simple quick start tutorial
- The market is right
- LVGL 8.2 Spinbox
- In depth understanding of service
- Millet 100W fast charging, 50W wireless charging technology exposure! Oppo Shen Yiren responded: boring!
- Chart is code: build a new generation of graphics library in a coded way -- feekin
- Metinfo function public function getcity() error: XXX function no permission load!!!
- Dark king | analysis of zego low illumination image enhancement technology
- Idea2021 installation
猜你喜欢

Style transfer -- CCPL: contrast coherence preserving loss for versatile style transfer

How to ensure data consistency between MySQL and redis?

中创算力荣获「2022年科技型中小企业」认定

Data link layer protocol -- Ethernet protocol
![[ CTF 学习 ] CTF 中的隐写集合 —— 图片隐写术](/img/32/2da78bd5866cfab9ee64dfcb1c1204.png)
[ CTF 学习 ] CTF 中的隐写集合 —— 图片隐写术

Kubesphere 3.3.0 offline installation tutorial

Paper:《Peeking Inside the Black Box: Visualizing Statistical Learning with Plots of Individual Condi

2019 telecast retest test questions

Summary of UPR optimization suggestions of unity

Pyg builds GCN to realize link prediction
随机推荐
一般在进行数仓迁移过程中,是如何进行数据测试的?
暗黑王者|ZEGO 低照度图像增强技术解析
Idea2021 installation
Thinking from the perspective of Aya
[sht30 temperature and humidity display based on STM32F103]
[cloud picture theory] 247 first introduction to Huawei cloud analysis service
Today is important
Introduction to FileStream class of C #
自然的状态最好
How to ensure data consistency between MySQL and redis?
今天很重要
Introduction to CpG control network
Network engineering case: integrated network design of CII company
GBase 8a 关于No Suitable Driver 问题
[daily question] 731. My schedule II
Construction of Seata multilingual system
956. Highest billboard pressure DP
Introduction to fundamentals of operations research [1]
Swagger simple quick start tutorial
When the development of the meta universe begins to show more and more the style of the Internet, we need to be vigilant