通过 Yarn 发布的包会托管在 上,用于全球分发。

如果你从未登录过,那就先创建一个 npm 账号。创建完成后,在 Yarn 里设置用户名和email。

这个命令会提示你输入用户名和 email, 但不需要输入密码。 Yarn 不保存你的密码,也不保持任何 Session。 当你真正发布或者修改 npm 上的包时,才需要输入密码。

首先,需要输入新的版本号:

之后,输入 npm 密码:

  1. [2/4] Logging in...
  2. info npm username: your-npm-username
  3. info npm username: you@example.com
  4. question npm password: ____________

最后,Yarn 将发布包并且注销你的会话。

你应该可以通过 来访问新上传的包,也可以通过以下命令安装:

  1. yarn add my-new-project

你也可以看到 npm registry 里的全部信息:

  1. { name: 'my-new-project',
  2. description: 'My New Project description.',
  3. 'dist-tags': { latest: '1.0.0' },
  4. versions: [ '1.0.0' ],
  5. maintainers: [ { name: 'Your Name', email: 'you@example.com' } ],
  6. { modified: '2018-12-05T09:28:54+00:00',
  7. '1.0.0': '2018-12-05T09:28:54+00:00' },
  8. homepage: 'https://my-new-project-website.com/',
  9. keywords: [ 'cool', 'useful', 'stuff' ],
  10. repository:
  11. { url: 'https://example.com/your-username/my-new-project',
  12. type: 'git' },
  13. contributors:
  14. [ { name: 'Your Friend',
  15. email: 'their-email@example.com',
  16. url: 'http://their-website.com' },
  17. { name: 'Another Friend',
  18. author: { name: 'Your Name', email: 'you@example.com' },
  19. bugs: { url: 'https://github.com/you/my-new-project/issues' },
  20. license: 'MIT',
  21. readmeFilename: 'README.md',
  22. version: '1.0.0',
  23. main: 'index.js',
  24. files: [ 'index.js', 'lib/*.js', 'bin/*.js' ],
  25. bin: { 'my-new-project-cli': 'bin/my-new-project-cli.js' },
  26. dist:
  27. { shasum: '908bc9a06fa4421e96ceda243c1ee1789b0dc763',
  28. tarball: 'https://registry.npmjs.org/my-new-project/-/my-new-project-1.0.0.tgz' },
  29. directories: {} }