The first step, npm init
just like git init. Will let you configure some parameters of this library in package.json.
~/documents/cli/minisite-cli > npm init
Press ^C at any time to quit.
name: (minisite-cli)
version: (1.0.0)
entry point: (index.js)
test command:
license: (MIT)
Generally, if your package.json is well written, you can press Enter and go all the way down.
Then npm login
log into your npm account. If not, go to npm to register one.
It can then be used npm publish
to upload your library.
common problem:
npm ERR! publish Failed PUT 403
npm ERR! Darwin 16.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "publish"
npm ERR! node v7.7.2
npm ERR! npm v4.1.2
npm ERR! code E403
npm ERR! no_perms Private mode enable, only admin can publish this module: minisite-cli
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /Users/yangzhedi/Documents/cli/minisite-cli/npm-debug.log
This may be because you have set npm as a Taobao mirror and need to set it back again.
npm config set registry http://registry.npmjs.org
npm ERR! Darwin 16.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "publish"
npm ERR! node v7.7.2
npm ERR! npm v4.1.2
npm ERR! code ENEEDAUTH
npm ERR! need auth auth required for publishing
npm ERR! need auth You need to authorize this machine using `npm adduser`
npm ERR! Please include the following file with any support request:
npm ERR! /Users/yangzhedi/Documents/cli/minisite-cli/npm-debug.log
You need to npm adduser
log in to your npm account.
Finally npm publish
it can be uploaded.
Appears to + [email protected]
indicate that your upload was successful