Yarn 发布包
为了通过 Yarn 共享你的包给全世界的者,你需要先发布它。
通过 Yarn 发布的包会托管在 上,用于全球分发。
如果你从未过,那就先。创建完成后,在 Yarn 里设置和email。
yarn login
这个命令会你输入和 email, 但不需要输入密码。 Yarn 不保存你的密码,也不保持任何 Session。 当你真正发布或者 npm 上的包时,才需要输入密码。
在你写完、测试通过、准备发布的时候,你可以执行:
yarn publish
首先,需要输入新的版本号:
[1/4] Bumping version... info Current version: 1.0.0 question New version: _____
之后,输入 npm 密码:
[2/4] Logging in... info npm username: your-npm-username info npm username: you@example.com question npm password: ____________
最后,Yarn 将发布包并且注销你的会话。
[3/4] Publishing... success Published. [4/4] Revoking token... success Revoked login token. ? Done in 10.53s.
每次发布都可以遵循上述流程。
你应该可以通过 https://www.npmjs.com/package/my-new-project 来访问新的包,也可以通过以下命令安装:
yarn add my-new-project
你也可以看到 npm registry 里的全部信息:
yarn info my-new-project
{ name: 'my-new-project', description: 'My New Project description.', 'dist-tags': { latest: '1.0.0' }, versions: [ '1.0.0' ], maintainers: [ { name: 'Your Name', email: 'you@example.com' } ], time: { modified: '2020-03-16T10:03:30+00:00', created: '2020-03-16T10:03:30+00:00', '1.0.0': '2020-03-16T10:03:30+00:00' }, homepage: 'https://my-new-project-website.com/', keywords: [ 'cool', 'useful', 'stuff' ], repository: { url: 'https://example.com/your-username/my-new-project', type: 'git' }, contributors: [ { name: 'Your Friend', email: 'their-email@example.com', url: 'http://their-website.com' }, { name: 'Another Friend', email: 'another-email@example.com', url: 'https://another-website.org' } ], author: { name: 'Your Name', email: 'you@example.com' }, bugs: { url: 'https://github.com/you/my-new-project/issues' }, license: 'MIT', readmeFilename: 'README.md', version: '1.0.0', main: 'index.js', files: [ 'index.js', 'lib/*.js', 'bin/*.js' ], bin: { 'my-new-project-cli': 'bin/my-new-project-cli.js' }, dist: { shasum: '908bc9a06fa4421e96ceda243c1ee1789b0dc763', tarball: 'https://registry.npmjs.org/my-new-project/-/my-new-project-1.0.0.tgz' }, directories: {} }