<h3 dir="auto">Current Behavior:</h3>
<p dir="auto">running <code class="notranslate">npm publish</code> get an error :</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="18 timing config:load Completed in 8ms
19 verbose npm-session 2c8eccb75d3455d8
20 timing npm:load Completed in 12ms
21 verbose publish [ '.' ]
22 timing command:publish Completed in 13ms
23 verbose stack TypeError [ERR_INVALID_ARG_TYPE]: The &quot;path&quot; argument must be of type string. Received undefined
23 verbose stack     at new NodeError (node:internal/errors:329:5)
23 verbose stack     at validateString (node:internal/validators:129:11)
23 verbose stack     at join (node:path:1081:7)
23 verbose stack     at flatten (/usr/lib/node_modules/npm/lib/utils/flat-options.js:50:10)
23 verbose stack     at Publish.publishConfigToOpts (/usr/lib/node_modules/npm/lib/publish.js:140:12)
23 verbose stack     at Publish.publish (/usr/lib/node_modules/npm/lib/publish.js:58:32)
24 verbose cwd /home/alban/dev/eda-vue-components
25 verbose Linux 4.19.104-microsoft-standard
26 verbose argv &quot;/usr/bin/node&quot; &quot;/usr/sbin/npm&quot; &quot;publish&quot; &quot;.&quot;
27 verbose node v15.11.0
28 verbose npm  v7.6.1
29 error code ERR_INVALID_ARG_TYPE
30 error The &quot;path&quot; argument must be of type string. Received undefined
31 verbose exit 1"><pre class="notranslate"><code class="notranslate">18 timing config:load Completed in 8ms
19 verbose npm-session 2c8eccb75d3455d8
20 timing npm:load Completed in 12ms
21 verbose publish [ '.' ]
22 timing command:publish Completed in 13ms
23 verbose stack TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
23 verbose stack     at new NodeError (node:internal/errors:329:5)
23 verbose stack     at validateString (node:internal/validators:129:11)
23 verbose stack     at join (node:path:1081:7)
23 verbose stack     at flatten (/usr/lib/node_modules/npm/lib/utils/flat-options.js:50:10)
23 verbose stack     at Publish.publishConfigToOpts (/usr/lib/node_modules/npm/lib/publish.js:140:12)
23 verbose stack     at Publish.publish (/usr/lib/node_modules/npm/lib/publish.js:58:32)
24 verbose cwd /home/alban/dev/eda-vue-components
25 verbose Linux 4.19.104-microsoft-standard
26 verbose argv "/usr/bin/node" "/usr/sbin/npm" "publish" "."
27 verbose node v15.11.0
28 verbose npm  v7.6.1
29 error code ERR_INVALID_ARG_TYPE
30 error The "path" argument must be of type string. Received undefined
31 verbose exit 1
</code></pre></div>
<h3 dir="auto">Expected Behavior:</h3>
<p dir="auto">it should be a success</p>
<h3 dir="auto">Steps To Reproduce:</h3>
<ul dir="auto">
<li>remove any "cache" config</li>
<li><code class="notranslate">npm publish</code> on a working project</li>
</ul>
<h3 dir="auto">Environment:</h3>
<p dir="auto">wsl archlinux<br>
node v15.11.0<br>
npm  v7.6.1</p>
<h3 dir="auto">workaround</h3>
<p dir="auto">adding "cache":"~/.npm" in package.json solves the problem.</p>
<h3 dir="auto">fix</h3>
<p dir="auto">I guess list[0] <a href="https://github.com/npm/cli/blob/latest/lib/publish.js#L140">here</a> is supposed to be the default config... but for any reason is not resolved... but I may be wrong here.</p>
<p dir="auto">I also notice <a href="https://github.com/npm/cli/blob/latest/lib/utils/flat-options.js#L50">https://github.com/npm/cli/blob/latest/lib/utils/flat-options.js#L50</a> is the only flatten option that is supposed not to be defined : maybe the problem is there ?</p>
<p dir="auto">Might be related to <a href="https://github.com/npm/cli/commit/6cd3cd08af56445e13757cac3af87f3e7d54ed27?branch=6cd3cd08af56445e13757cac3af87f3e7d54ed27&amp;diff=split#diff-49d92972c12c110929e2654444cef752a7d1fbf52ad3715ce8667257f68ab464R42">this change</a> (the code was <code class="notranslate"> cache: join(npm.config.get('cache'), '_cacache'),</code> before, maybe get use default value if any ?</p>
<h3 dir="auto">Current Behavior:</h3>
<p dir="auto">When running <code class="notranslate">npm publish</code> the following error appears:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="npm ERR! code ERR_INVALID_ARG_TYPE
npm ERR! The &quot;path&quot; argument must be of type string. Received undefined

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/xx/.npm/_logs/2021-03-06T09_10_43_193Z-debug.log"><pre class="notranslate"><code class="notranslate">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/xx/.npm/_logs/2021-03-06T09_10_43_193Z-debug.log
</code></pre></div>
<p dir="auto">The debug trace shows:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="23 verbose stack TypeError [ERR_INVALID_ARG_TYPE]: The &quot;path&quot; argument must be of type string. Received undefined
23 verbose stack     at validateString (internal/validators.js:124:11)
23 verbose stack     at join (path.js:1039:7)
23 verbose stack     at flatten (/home/xx/.nvm/versions/node/v14.16.0/lib/node_modules/npm/lib/utils/flat-options.js:50:10)
23 verbose stack     at Publish.publishConfigToOpts (/home/xx/.nvm/versions/node/v14.16.0/lib/node_modules/npm/lib/publish.js:140:12)
23 verbose stack     at Publish.publish (/home/xx/.nvm/versions/node/v14.16.0/lib/node_modules/npm/lib/publish.js:58:32)"><pre class="notranslate"><code class="notranslate">23 verbose stack TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
23 verbose stack     at validateString (internal/validators.js:124:11)
23 verbose stack     at join (path.js:1039:7)
23 verbose stack     at flatten (/home/xx/.nvm/versions/node/v14.16.0/lib/node_modules/npm/lib/utils/flat-options.js:50:10)
23 verbose stack     at Publish.publishConfigToOpts (/home/xx/.nvm/versions/node/v14.16.0/lib/node_modules/npm/lib/publish.js:140:12)
23 verbose stack     at Publish.publish (/home/xx/.nvm/versions/node/v14.16.0/lib/node_modules/npm/lib/publish.js:58:32)
</code></pre></div>
<h3 dir="auto">Expected Behavior:</h3>
<p dir="auto">npm publish to continue working as it did in version 6</p>
<h3 dir="auto">Steps To Reproduce:</h3>
<ol dir="auto">
<li>In this environment...<br>
Ubuntu 20.04<br>
Node 14.16.0<br>
npm 7.6.1</li>
<li>With this config...<br>
The package is configured to be published to github as per: <a href="https://docs.github.com/en/packages/guides/configuring-npm-for-use-with-github-packages#publishing-a-package-using-publishconfig-in-the-packagejson-file">github instrutions</a></li>
</ol>
<p dir="auto">package.json includes:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  &quot;publishConfig&quot;: {
    &quot;registry&quot;: &quot;https://npm.pkg.github.com&quot;
  },"><pre class="notranslate"><code class="notranslate">  "publishConfig": {
    "registry": "https://npm.pkg.github.com"
  },
</code></pre></div>
<ol start="3" dir="auto">
<li>Run <code class="notranslate">npm publish</code></li>
<li>See error:</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="npm ERR! code ERR_INVALID_ARG_TYPE
npm ERR! The &quot;path&quot; argument must be of type string. Received undefined`"><pre class="notranslate"><code class="notranslate">npm ERR! code ERR_INVALID_ARG_TYPE
npm ERR! The "path" argument must be of type string. Received undefined`
</code></pre></div>
<h3 dir="auto">Environment:</h3>
<p dir="auto">Ubuntu 20.04<br>
Node 14.16.0<br>
npm 7.6.1</p>
<h3 dir="auto">Possible cause</h3>
<p dir="auto">The issue seems to be related to changes made to the <code class="notranslate">flatten()</code> method in <a href="https://github.com/npm/cli/blob/08673c34f0f131619ea8eb75dd325e755bf0a323/lib/utils/flat-options.js#L50">utils/flat-options.js</a><br>
This is being called with the <code class="notranslate">publishConfig</code> which only contains a <code class="notranslate">registry</code> property.<br>
However flatten (line 50), tries to use <code class="notranslate">join()</code> to create a path from the non-existent<code class="notranslate">'cache</code> property, hence the error (I believe).<br>
Looking at the changes, it seems that v6 used to read the npm config for the <code class="notranslate">cache</code> value.</p>
<h3 dir="auto">Workaround</h3>
<p dir="auto">My temporary workaround for this is to add a <strong>cache</strong> property to the publishConfig section, using the <a href="https://docs.npmjs.com/cli/v7/using-npm/config#cache" rel="nofollow">default cache value</a>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  &quot;publishConfig&quot;: {
    &quot;cache&quot;: &quot;~/.npm&quot;,
    &quot;registry&quot;: &quot;https://npm.pkg.github.com&quot;
  },"><pre class="notranslate"><code class="notranslate">  "publishConfig": {
    "cache": "~/.npm",
    "registry": "https://npm.pkg.github.com"
  },
</code></pre></div>
<p dir="auto">As others have noted, this workaround has the side-effect of creating a <code class="notranslate">~/.npm</code> directory in the root of the project. My solution to this was then simply to add <code class="notranslate">~/.npm</code> to <code class="notranslate">.gitgnore</code></p>
<p dir="auto">I guess that you could name this cache directory whatever you like. I used the default value simply to make publish work again. Note that my suggestion is purely a workaround and doesn't resolve the actual issue. Although I could see in the v7 code where the change has been made that is causing this issue, unfortunately I was unable to understand why that change was made.</p>