In a JavaScript monorepo managed with Rush, I have three projects:
backend/frontend/shared/
In backend/package.json and frontend/package.json, the shared project is declared as a dependency:
"dependencies": {
"shared": "0.0.0",
In the local environment, everything works fine, thanks to Rush, which runs npm link for me.
Now I need to publish.
On the frontend project, the command rushx build (like npm run build) creates JS and CSS bundles with the help of webpack, and puts them in the backend/ directory.
I would like to publish the backend project as a real package on npmjs. I don't want to publish shared as a distinct package because in the published version it is not shared anymore. The shared content is already bundled in the frontend. I would like to embed it into the backend too.
I tried to pack it:
cd backend/
npm pack ../shared
# A new file is created: 'shared-0.0.0.tgz'
Then I edited backend/package.json:
"dependencies": {
"shared": "shared-0.0.0.tgz",
But after that the generated package doesn't work. When I execute npm install my-published-package, it tries to find shared-0.0.0.tgz in the current directory instead of the installed package directory.
Is there an elegant solution?