Is it possible to publish a package that makes use of internal dependencies like
"@me/internal-dep": "file:packages/internal-dep"
Minimally Reproducable Example
https://github.com/rphovley/publishing-workspaces-test
In my root package.json
, I have:
{
"name": "@me/my-package",
"version": "1.0.0",
"workspaces": [
"packages/*"
],
"bin": {
"my-package": "./bin/run.js"
},
"dependencies": {
"@me/internal-dep": "file:packages/internal-dep"
}
}
This works fine locally and with npm pack
, but when I publish the package and try to install it globally (npm install -g @me/my-package
), I get the following error:
24 verbose stack TypeError: Cannot set properties of null (setting 'dev')
It appears there’s more than just an npm install
going on as this issue hints at the symlink not working well on the global installation. What’s interesting is if the user runs npm i -g npm
and updates npm, the global installation of the package works as expected.
I’ve checked to see if the npm version update is consequential, but it’s not. I’m able to recreate the issue on npm version 10.8.1 and it updates to 10.8.2 and there’s nothing I can see in the changelog that would warrant fixing this behavior.
Is there another way to do this besides having to publish the internal packages to npm? The packages code is sent as part of the code that’s installed to the device, so it feels like this should be possible