npm publish fails with "The "path" argument must be of type string. Received undefined"
Asked Answered
F

1

7

I have a project that i publish on a private npm repository. Under node v14.16.0 (npm v6.14.11), the command npm publish run well and my package is published on my private repository.

I upgraded npm to 7 to support peer dependencies installation. Now under node v15.12.0 (npm v7.6.3), the command npm publish fails with

The "path" argument must be of type string. Received undefined

Any idea?

Update

npm 7.6.3 with node 14 as the same effect :

The "path" argument must be of type string

Update 2

console output with flag --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 [email protected] npm info using [email protected] 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)

Forsake answered 18/3, 2021 at 16:16 Comment(4)
If a clean npm install doesn't help, you could try downgrading node to v14. Tools like n (#4245396) and github.com/nvm-sh/nvm will help with this.Hawaiian
@KunalNagpal npm 7.6.3 with node 14 as the same effect : The "path" argument must be of type stringForsake
Okay, could you try: npm publish --verbose?Hawaiian
@KunalNagpal I added the output console to the questionForsake
F
12

I found the issue here

The workaround is to add a cache property to the publishConfig section of package.json

"publishConfig": {
    "cache": "cache/.npm",
    "registry": "https://mydomain/myrepo"
}

Update

The issue has been fixed in npm 7.7.0

Forsake answered 19/3, 2021 at 8:10 Comment(5)
The problem has since been fixed, as indicated in the issue you link to, in npm 7.7.0.Trave
I'm on 7.9.0 and experience the issueHourly
@Hourly any solution?Airwaves
@Airwaves - sorry but I don't remember. Try remove the publishConfig property completelyHourly
but that will remove registry info as well.Airwaves

© 2022 - 2024 — McMap. All rights reserved.