Creating packages consumable through npm install
#3607
Replies: 1 comment 3 replies
-
Yarn and npm are similar but different ways to manage a project. While they're often converging on features, they aren't interchangeable. If you limit your project to the small subset of features that work across both you might be able to get this to work, but it wouldn't make sense. It's a lot of work to restrict yourself (and team) for no real value. If you want to use a yarn monorepo to develop (I do!) you can't use npm with it. I'm the author of yarn.build. The You can do the same by running A key thing to note here is that with either yarn by itself, or the zip you get from I think what you want to do it quite possible, just you don't need npm for it at all. |
Beta Was this translation helpful? Give feedback.
-
I am new to Yarn 2/3, and wanted to find out if there is a prescribed way to make Yarn monorepos available to be consumed by non-Yarn packages. Ideally, I would like to be able to produce a tarball that another Node project could install through
npm install
. I am not looking to publish the monorepo workspaces to npm registry (public or private)I have looked at
yarn npm publish
but that appears to be geared towards actually publishing to the npm registry, with seemingly no opportunity to make it quit after generating a publishable package. In fact, it will not proceed without npm registry credentials. I could potentially set up a localhost registry but hoping I don't have to.I have looked at
yarn pack
which creates a compressed archive of all the files in the monorepo, but the resulting.tgz
is not directly usable bynpm
because npm doesn't understand theworkspace:
protocol, which is how I do internal referencing between monorepo packages. It also doesn't include any of the dependencies from.yarn/cache
. I was hoping thatyarn pack
would either generate good oldnode_modules
or would produce the right scaffolding sonpm
can resolve dependencies using.pnp.cjs
Lastly, I have also looked at
yarn.build
(https://github.com/ojkelly/yarn.build), but that doesn't appear to produce a package that can be directly installed bynpm install path/to/.tgz
Beta Was this translation helpful? Give feedback.
All reactions