How do I log in using only the CLI?

758 Views Asked by At

I'm using the following environment with WSL2.

❯ npm -version
10.0.0

❯ node -v
v20.6.0

❯ cat /etc/debian_version
12.1

I tried npm login and got the following error.

❯ npm login
npm notice Log in on https://registry.npmjs.org/
Login at:
https://www.npmjs.com/login?next=/login/cli/24c20e4f-67dc-4103-af15-95776747623c
Press ENTER to open in the browser...
npm ERR! code ERR_INVALID_ARG_TYPE
The "file" argument must be of type string.
Cannot read properties of undefined (reading 'stdin')

A complete log of this run can be found in: /home/masyuko0222/.npm/_logs/2023-09-07T12_55_35_293Z-debug-0.log

I'm having trouble understanding what this The "file" argument refers to.

Or is the error occurring because you are trying to open the browser from WSL2? If so, should I try downgrading the npm version?

Please advise.

I've tried this answer

1

There are 1 best solutions below

2
On

Try using legacy auth-type for login from CLI

npm login --auth-type legacy