最近一直在研習關於node的知識,發佈包雖然是最基礎的一點,但因爲一些地方的不注意很容易發生錯誤,我整理了我可能出現過的一些發佈包的過程當中的一些error,如今分享給你們:
正確的發包步驟:node
不夠清楚?上圖npm
npm ERR! need auth auth and email requiredfor publishing
npm ERR! need auth You need to authorize this machine using npm adduser
json
錯誤。ui
npm ERR! publish Failed PUT 403
npm ERR! Error: no_perms Private modeenable, only admin can publish this module: nodebb-plugin-route-cms
有至少兩種方法:命令:npm adduser
1)修改~/.npmrc中的registry字段(命令:vi ~/.npmrc)
2)直接在命令行修改便可。this
不夠清楚?繼續上圖!spa
npm ERR! addLocal Could not install .
npm ERR! Error: EACCES, open'/home/jiangcaiyang/.npm/nodebb-plugin-route-cms/0.0.1/package/package.json'
npm ERR! { [Error: EACCES, open'/home/jiangcaiyang/.npm/nodebb-plugin-route-cms/0.0.1/package/package.json']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path:'/home/jiangcaiyang/.npm/nodebb-plugin-route-cms/0.0.1/package/package.json' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
--tag的意思是標記版本號。這裏按照semver的標準來制定版本(參考這裏)
版本格式:主版號.次版號.修訂號,版號遞增規則以下:命令行
主版號:當你作了不相容的API 修改,code
次版號:當你作了向下相容的功能性新增,blog
修訂號:當你作了向下相容的問題修正。圖片
先行版號及版本編譯資訊能夠加到「主版號.次版號.修訂號」的後面,做爲延伸。
最後繼續以一張圖片來結尾,結束咱們的此次分享
在大型項目的建設過程當中,不少細小的錯誤都會讓咱們花費巨大的時間成本去完成,因此若是可以提早知道防患於未然就顯得尤其重要了。