Skip to content
New issue

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. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] error publish without cache config in package.json / publishConfig #2842

Closed
neyb opened this issue Mar 9, 2021 · 7 comments
Closed
Assignees
Labels
Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release

Comments

@neyb
Copy link

neyb commented Mar 9, 2021

Current Behavior:

running npm publish get an error :

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

Expected Behavior:

it should be a success

Steps To Reproduce:

  • remove any "cache" config
  • npm publish on a working project

Environment:

wsl archlinux
node v15.11.0
npm v7.6.1

workaround

adding "cache":"~/.npm" in package.json solves the problem.

fix

I guess list[0] here is supposed to be the default config... but for any reason is not resolved... but I may be wrong here.

I also notice https://github.com/npm/cli/blob/latest/lib/utils/flat-options.js#L50 is the only flatten option that is supposed not to be defined : maybe the problem is there ?

Might be related to this change (the code was cache: join(npm.config.get('cache'), '_cacache'), before, maybe get use default value if any ?

@neyb neyb added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Mar 9, 2021
@neyb
Copy link
Author

neyb commented Mar 9, 2021

note : might also be the cause of #2843 (also seems to miss a default config)

@malsatin
Copy link

@like-me4
Copy link

Updated npm and got the same problem. On version 7.5.4 everything worked well.

@pmclachlan
Copy link

pmclachlan commented Mar 14, 2021

Same bug.

A note for others, at least for me, the workaround line ("cache": "~/.npm") needed to be added inside publishConfig in package.json, not at the top level.

(Actually, getting a bunch of other weird bugs on this latest version too -- will have to roll back. For example, even after the workaround, after I publish, when I 'npm install mything@latest' it doesn't actually pick up the newly published version. I rolled back to 7.5.6 and my usual workflow (npm publish; cd ../other; npm install mything@latest ) started working again.

@wraithgar wraithgar self-assigned this Mar 15, 2021
@wraithgar wraithgar removed the Needs Triage needs review for next steps label Mar 15, 2021
@wraithgar
Copy link
Member

wraithgar commented Mar 15, 2021

I believe this PR may fix the issue: #2865

If you define a publishConfig, it pushes the defaults out the window, that PR makes sure all publishConfigs (including the defualts) are represented in the final opts that are generated.

@neyb
Copy link
Author

neyb commented Mar 16, 2021

oO it seems to be a duplicate of #2834

@neyb
Copy link
Author

neyb commented Mar 18, 2021

duplicate of #2834

@neyb neyb closed this as completed Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

5 participants