λ npm init // 建包,信息填写好
λ npm adduser // 创建npm账户 填写账号,密码,邮箱
λ npm whoami // 查看当前登录的是谁
ajanuw
登录
λ npm login
Username: ajanuw
Password:
Email: (this IS public) ajanuw1641845087@sina.com
Logged in as ajanuw on https://registry.npm.taobao.org/.
λ npm logout // 退出登录
查看当前所在位置包的信息
λ npm version
{ 'npm-publish-helloworld': '1.0.0',
npm: '5.6.0',
ares: '1.14.0',
cldr: '33.0',
http_parser: '2.8.0',
icu: '61.1',
modules: '64',
napi: '3',
nghttp2: '1.29.0',
node: '10.2.0',
openssl: '1.1.0h',
tz: '2018c',
unicode: '10.0',
uv: '1.20.3',
v8: '6.6.346.32-node.8',
zlib: '1.2.11'
λ npm version 1.0.1 // 改变当前包的版本,package.json 也会改变
λ npm version
{ 'npm-publish-helloworld': '1.0.1',
查看npm配置
λ npm config list
λ npm config set registry http://registry.npmjs.org/ // 把原来配置的淘宝源切换回npm
λ npm whoami // 切换后再看下当前登录的用户
发布
λ npm publish
+ ajanuw-npm-publish-helloworld@1.0.0
再次发布
添加 README.md 文件, 为包做说明
λ npm version 1.0.1 // 设置下一个版本
v1.0.1
λ npm publish
+ ajanuw-npm-publish-helloworld@1.0.1
安装
λ yarn add ajanuw-npm-publish-helloworld