.npmignore和.gitignore
Use a
.npmignore
file to keep stuff out of your package. If there’s no.npmignore
file, but there is a.gitignore
file, then npm will ignore the stuff matched by the.gitignore
file. If you want to include something that is excluded by your.gitignore
file, you can create an empty.npmignore
file to override it.
.npmignore
決定publish之後哪些文件被髮布。
.gitignore
決定哪些文件被git跟蹤
當npmignore
不存在時,發佈時匹配.gitignore
中忽略文件
當.npmignore
和.gitignore
同時存在,優先讀取.npmignore
若希望被.gitignore
忽略的文件,發佈之後還有,則建一個空的.npmignore
文件來覆蓋.gitignore
測試.npmignore忽略的文件
可以在本地運行npm pack
命令,該命令將在工作目錄中生成壓縮包,與發佈時相同
README.md
編寫包的介紹文檔
發佈
#登錄
npm login
#輸入用戶名密碼
#發佈
npm publish
語義化版本
發佈包應該遵循語義化版本規範
點擊查看詳情
包版本的更新
當前版本爲1.0.0,修改本地版本
npm version patch
版本變爲1.0.1npm version minor
版本變爲1.1.0npm version major
版本變爲2.0.0
git tag
#附註標籤
git tag -a 標籤(一般是版本號) -m "詳細解釋"
#輕量標籤
git tag 標籤
#查看某一個標籤
git show [標籤]
#列出所有的標籤
git tag
#給某個歷史提交(commitId)打標籤
git tag 標籤 commitId
#刪除標籤
git branch -d 標籤名
#將某個標籤提交到遠程
git push origin 標籤名
#將所有的標籤提交到遠程
git push origin --tags