How to publish a package to private npm registry using yarn berry

1k views Asked by At

I am working on a private internal package; it is a common components library used by a couple of different repositories for the company I work for. I recently migrated the repository containing the common components from yarn 1 to yarn berry (3.3.1) - there were no issues with the migration itself.

The problem I am experiencing is while publishing a new package of the library to our private npm repo. Prior to migrating, publishing was very simple:

I'd simply run yarn publish and the terminal would prompt me for my login info and to enter the package's new version (basically this: https://classic.yarnpkg.com/lang/en/docs/publishing-a-package/), and the package would be published and could be used.

Since upgrading I now run yarn npm publish and that takes whatever is in my files section of package.json and packages it up into a zip file, so in my case the following:

    "files": [
        "dist/*/**",
        "src/assets"
    ],

This appears to be fine. However, when I go and install that package in another repo the contents do not match what was published. I used yarn link to verify the package was working during development, I also used yalc to test that the packaged version was working as well.

I'm well aware that this could entirely be a user error on my part. I've looked in the documentation for help with this but was not really able to find an answer:

How can I set up my project to properly package its contents and publish them to the private npm registry?

Contents of .yarnrc.yml file

npmRegistryServer: "<redacted>"
npmPublishRegistry: "<redacted>"

plugins:
  - path: .yarn/plugins/@yarnpkg/plugin-constraints.cjs
    spec: "@yarnpkg/plugin-constraints"

pnpMode: loose

yarnPath: .yarn/releases/yarn-3.3.1.cjs

enableStrictSsl: false
1

There are 1 answers

0
MiniSkoot32 On

Usage $> yarn npm publish

Table of other options here

Details This command will pack the active workspace into a fresh archive and upload it to the npm registry.

The package will by default be attached to the latest tag on the registry, but this behavior can be overriden by using the --tag option.

Note that for legacy reasons scoped packages are by default published with an access set to restricted (aka "private packages"). This requires you to register for a paid npm plan. In case you simply wish to publish a public scoped package to the registry (for free), just add the --access public flag. This behavior can be enabled by default through the npmPublishAccess settings.