Publishing a Package

In order to share your package with other developers around the world through Yarn, you’ll first need to publish it.

When you publish a package with Yarn it goes onto the npm registry which is used to distribute packages globally.

Logging into npm

If you haven’t already, you’ll first need to create an npm account. Once you’ve done that you can setup your username and email in Yarn.

yarn login

This will prompt you for your username and email. However, it will not ask you for your password. Yarn does not hold onto your password or any sessions. When you go to publish or modify something on npm, you will need to enter your password then.

Publishing your package

Once you have written all the code in your package, tested it out and you are ready to publish you can kick things off:

yarn publish

First you will be asked to enter a new version to publish:

[1/4] Bumping version...
info Current version: 1.0.0
question New version: _____

Next you will be asked to enter your npm password:

[2/4] Logging in...
info npm username: your-npm-username
info npm username:
question npm password: ____________

Finally, Yarn will publish the package and revoke your session token.

[3/4] Publishing...
success Published.
[4/4] Revoking token...
success Revoked login token.
✨  Done in 10.53s.

Each time you want to publish a new version of your package you can follow this same flow.

Accessing your package

Your package should now be available at and you should be able to install it:

yarn add my-new-project

You can also see all the info in the 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: '' } ],
  { modified: '2017-07-19T17:05:50+00:00',
    created: '2017-07-19T17:05:50+00:00',
    '1.0.0': '2017-07-19T17:05:50+00:00' },
  homepage: '',
  keywords: [ 'cool', 'useful', 'stuff' ],
   { url: '',
     type: 'git' },
   [ { name: 'Your Friend',
       email: '',
       url: '' },
     { name: 'Another Friend',
       email: '',
       url: '' } ],
  author: { name: 'Your Name', email: '' },
  bugs: { url: '' },
  license: 'MIT',
  readmeFilename: '',
  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' },
   { shasum: '908bc9a06fa4421e96ceda243c1ee1789b0dc763',
     tarball: '' },
  directories: {} }