1.先到npm官網註冊一個賬號
NPM官網
2.新建一個資料夾,初始化一個專案
mkdir npm-test
cd npm-test
touch index.js
vim index.js
複製程式碼
index.js
新增內容
exports.demo = (param) => {
console.log('hello ' + param)
}
複製程式碼
然後npm init
注意:
1.包名不要包含demo字樣,會觸發垃圾檢測,不能有大寫字母/空格/下滑線
2.npm映象源不要連線代理,切換到官網地址
3.私密程式碼寫入.gitignore
或.npmignore
中,上傳就會被忽略了
npm config set registry http://registry.npmjs.org/
npm init
複製程式碼

新增賬戶
npm adduser
複製程式碼

釋出包
npm publish
複製程式碼

我們來檢驗下


成功了,沒毛病~~
刪除NPM包
npm unpublish 包名 --force
複製程式碼

over~大家上傳包還是仔細點~~