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

@pnpm/npm-conf: The "path" argument must be of type string error when env.APPDATA is undefined on Windows #6659

Closed
RandomByte opened this issue Jun 9, 2023 · 3 comments · Fixed by #6672

Comments

@RandomByte
Copy link

This is a report of a possible regression in the @pnpm/npm-conf package. We use this package as a transitive dependency of update-notifier, via registry-auth-token.

A user of our package reported the error described below when using it in a Windows environment were the APPDATA environment variable is not set (e.g. the Visual Studio Code terminal): SAP/ui5-tooling#833

It looks like a regression to me, since exactly this behavior has been fixed in the original module in the past : kevva/npm-conf#7

I think the issue got re-introduced in your fork with this commit: pnpm/npm-conf@ccf74c4#diff-b34f2f53ab94368c86775969fb604e8375abe03b6a378bdd09896fd91ac0a0d2R30

pnpm version: None

@pnpm/npm-conf version: 2.2.0

Code to reproduce the issue:

Note: For the lack of a Windows system, I haven't tested this myself. But based on the report, I would expect the following code to produce the error on a Windows system:

process.env.APPDATA = undefined;
require("@pnpm/npm-conf")()

Expected behavior:

Module should initialize fine on Windows, even if the APPDATA environment variable is not set.

Actual behavior:

Module throws an error The "path" argument must be of type string. Received undefined

Additional information:

  • node -v prints: 18.16.0
  • Windows, macOS, or Linux?: Windows 11
@qianhaiyang
Copy link

qianhaiyang commented Jun 10, 2023

This bug prevents me from installing pnpm under Windows.

When I execute the xxx command, the following error occurs:

Downloading pnpm from GitHub...

Running setup...

node:internal/errors:466
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:377:5)
    at validateString (node:internal/validators:119:11)
    at Object.resolve (node:path:167:9)
    at ../node_modules/.pnpm/@pnpm+npm-conf@2.2.0/node_modules/@pnpm/npm-conf/lib/defaults.js (C:\snapshot\dist\pnpm.cjs)
    at __require (C:\snapshot\dist\pnpm.cjs)
    at ../node_modules/.pnpm/@pnpm+npm-conf@2.2.0/node_modules/@pnpm/npm-conf/index.js (C:\snapshot\dist\pnpm.cjs)
    at __require (C:\snapshot\dist\pnpm.cjs)
    at ../config/config/lib/index.js (C:\snapshot\dist\pnpm.cjs)
    at __require (C:\snapshot\dist\pnpm.cjs)
    at ../cli/cli-utils/lib/getConfig.js (C:\snapshot\dist\pnpm.cjs) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Node.js v18.1.0

I tried APPDATA in the user environment variable, but it still didn't work.

Is there any way to temporarily fix the error?

@zkochan
Copy link
Member

zkochan commented Jun 14, 2023

@RandomByte thanks for the detailed issue.

I have published a fix into @pnpm/npm-conf@2.2.2

@seyaobey
Copy link

I am facing the same issue with version 8.12.0. In my case, this error appears only when I attempt to install dev dependencies with the -D option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants