Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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)

like image 261
Troopers Avatar asked Mar 18 '21 16:03

Troopers


People also ask

What are the requirements for path arguments in NPM err?

The "path" argument must be of type string. Received undefined npm ERR! A complete log of this run can be found in: npm ERR! /home/garax/.npm/_logs/2021-03-19T14_44_29_986Z-debug.log

Where can I find NPM err error code ERR_invalid_ARG_type?

npm ERR! code ERR_INVALID_ARG_TYPE npm ERR! The "path" argument must be of type string. Received undefined npm ERR! A complete log of this run can be found in: npm ERR! /home/garax/.npm/_logs/2021-03-19T14_44_29_986Z-debug.log

What type of string should the path argument be?

The "path" argument must be of type string. Received type undefined · Issue #354 · tschaub/gh-pages · GitHub Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community. By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement.

What is the type of the path argument in tschaub/GH-pages/354?

Received type undefined #354 The "path" argument must be of type string. Received type undefined #354 Loading status checks… Loading status checks… To work around tschaub/gh-pages#354.


1 Answers

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

like image 183
Troopers Avatar answered Nov 01 '22 03:11

Troopers