I am trying to publish a package that relies on an unpublished package, which needs to remain unpublished. I thought I had a solution:
In development, the relative path is hardcoded in the package.json:
{
...
"dependencies": {
"@company/dependency": "file:../lib"
},
"bundledDependencies": {
"@company/dependency"
}
}
In the deployment pipeline, the dependency is npm pack
'd, then that tar is written to the above package:
"@company/dependency": "file:../lib/company-dependency-version.tgz"
The module is then published. It seems to work fine in the consuming app when installed directly: npm install @company/published-module
, but when npm i
is run, I get the following error:
$ npm install
npm ERR! code ENOENT
npm ERR! syscall stat
npm ERR! path C:\...\node_modules\lib\company-dependency-version.tgz
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, stat 'C:\...\node_modules\lib\company-dependency-version.tgz'
npm ERR! enoent This is related to npm not being able to find a file.
It seems that when the package is checked in npm install, it follows the relative path from wherever the module is in node_modules and looks for the tar file, then abandons the npm install
. If I skip the tar, it will still seek out the module per the relative path provided here.
I have seen questions about people using bundledDependencies to publish with local modules, but I haven't seen this issue come up. What am I missing here?