npm 发布失败,"The " 路径“参数必须是字符串类型。接收未定义”
npm publish fails with "The "path" argument must be of type string. Received undefined"
我有一个在私人 npm 存储库上发布的项目。
在 node v14.16.0 (npm v6.14.11)
下,命令 npm publish
运行 好吧,我的包已发布到我的私有存储库中。
我将 npm 升级到 7 以支持对等依赖项安装。
现在在 node v15.12.0 (npm v7.6.3)
下,命令 npm publish
失败
The "path" argument must be of type string. Received undefined
有什么想法吗?
更新
npm 7.6.3 与节点 14 效果相同:
The "path" argument must be of type string
更新 2
带有标志的控制台输出 --verbose
npm verb cli [ npm verb cli
'.nvm/versions/node/v15.12.0/bin/node', npm
verb cli
'.nvm/versions/node/v15.12.0/bin/npm', npm verb
cli 'publish', npm verb cli '--verbose' npm verb cli ] npm info
using npm@7.6.3 npm info using node@v15.12.0 npm timing
config:load:defaults Completed in 3ms npm timing
config:load:file:.nvm/versions/node/v15.12.0/lib/node_modules/npm/npmrc
Completed in 2ms npm timing config:load:builtin Completed in 2ms npm
timing config:load:cli Completed in 2ms npm timing config:load:env
Completed in 0ms npm timing
config:load:file:MyProject/.npmrc
Completed in 4ms npm timing config:load:project Completed in 5ms npm
timing config:load:file:.npmrc Completed in 4ms
npm timing config:load:user Completed in 4ms npm timing
config:load:file:.nvm/versions/node/v15.12.0/etc/npmrc
Completed in 1ms npm timing config:load:global Completed in 1ms npm
timing config:load:cafile Completed in 0ms npm timing
config:load:validate Completed in 0ms npm timing
config:load:setUserAgent Completed in 1ms npm timing
config:load:setEnvs Completed in 0ms npm timing config:load Completed
in 18ms npm verb npm-session 83e5ee6d9b1b9659 npm timing npm:load
Completed in 82ms npm verb publish [ '.' ] npm timing command:publish
Completed in 25ms npm verb stack TypeError [ERR_INVALID_ARG_TYPE]: The
"path" argument must be of type string. Received undefined npm verb
stack at new NodeError (node:internal/errors:329:5) npm verb stack
at validateString (node:internal/validators:129:11) npm verb stack
at join (node:path:1081:7) npm verb stack at flatten
(.nvm/versions/node/v15.12.0/lib/node_modules/npm/lib/utils/flat-options.js:50:10)
npm verb stack at Publish.publishConfigToOpts
(.nvm/versions/node/v15.12.0/lib/node_modules/npm/lib/publish.js:140:12)
npm verb stack at Publish.publish
(.nvm/versions/node/v15.12.0/lib/node_modules/npm/lib/publish.js:58:32)
我发现了问题 here
解决方法是将 cache
属性 添加到 package.json
的 publishConfig
部分
"publishConfig": {
"cache": "cache/.npm",
"registry": "https://mydomain/myrepo"
}
更新
该问题已在 npm 7.7.0 中修复
我有一个在私人 npm 存储库上发布的项目。
在 node v14.16.0 (npm v6.14.11)
下,命令 npm publish
运行 好吧,我的包已发布到我的私有存储库中。
我将 npm 升级到 7 以支持对等依赖项安装。
现在在 node v15.12.0 (npm v7.6.3)
下,命令 npm publish
失败
The "path" argument must be of type string. Received undefined
有什么想法吗?
更新
npm 7.6.3 与节点 14 效果相同:
The "path" argument must be of type string
更新 2
带有标志的控制台输出 --verbose
npm verb cli [ npm verb cli
'.nvm/versions/node/v15.12.0/bin/node', npm verb cli
'.nvm/versions/node/v15.12.0/bin/npm', npm verb cli 'publish', npm verb cli '--verbose' npm verb cli ] npm info using npm@7.6.3 npm info using node@v15.12.0 npm timing config:load:defaults Completed in 3ms npm timing config:load:file:.nvm/versions/node/v15.12.0/lib/node_modules/npm/npmrc Completed in 2ms npm timing config:load:builtin Completed in 2ms npm timing config:load:cli Completed in 2ms npm timing config:load:env Completed in 0ms npm timing config:load:file:MyProject/.npmrc Completed in 4ms npm timing config:load:project Completed in 5ms npm timing config:load:file:.npmrc Completed in 4ms npm timing config:load:user Completed in 4ms npm timing config:load:file:.nvm/versions/node/v15.12.0/etc/npmrc Completed in 1ms npm timing config:load:global Completed in 1ms npm timing config:load:cafile Completed in 0ms npm timing config:load:validate Completed in 0ms npm timing config:load:setUserAgent Completed in 1ms npm timing config:load:setEnvs Completed in 0ms npm timing config:load Completed in 18ms npm verb npm-session 83e5ee6d9b1b9659 npm timing npm:load Completed in 82ms npm verb publish [ '.' ] npm timing command:publish Completed in 25ms npm verb stack TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined npm verb stack at new NodeError (node:internal/errors:329:5) npm verb stack at validateString (node:internal/validators:129:11) npm verb stack
at join (node:path:1081:7) npm verb stack at flatten (.nvm/versions/node/v15.12.0/lib/node_modules/npm/lib/utils/flat-options.js:50:10) npm verb stack at Publish.publishConfigToOpts (.nvm/versions/node/v15.12.0/lib/node_modules/npm/lib/publish.js:140:12) npm verb stack at Publish.publish (.nvm/versions/node/v15.12.0/lib/node_modules/npm/lib/publish.js:58:32)
我发现了问题 here
解决方法是将 cache
属性 添加到 package.json
publishConfig
部分
"publishConfig": {
"cache": "cache/.npm",
"registry": "https://mydomain/myrepo"
}
更新
该问题已在 npm 7.7.0 中修复