我正在尝试发布依赖于未发布的程序包的程序包,该程序包需要保持未发布状态。我以为我有解决办法:
在开发中,相对路径被硬编码在package.json中:
{
...
"dependencies": {
"@company/dependency": "file:../lib"
},
"bundledDependencies": {
"@company/dependency"
}
}
在部署管道中,将依存关系为npm pack
,然后将tar写入上述程序包:
"@company/dependency": "file:../lib/company-dependency-version.tgz"
然后发布该模块。直接安装npm install @company/published-module
时,在消费类应用程序中似乎可以正常工作,但是运行npm i
时,出现以下错误:
$ 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.
似乎在npm install中检查软件包时,它将遵循该模块从node_modules中任何位置的相对路径,并查找tar文件,然后放弃npm install
。如果我跳过tar,它仍然会按照此处提供的相对路径查找模块。
我已经看到了有关人们使用bundledDependencies与本地模块一起发布的问题,但是我还没有看到这个问题。我在这里想念什么?