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

Error with npm v9+: npm access 2fa-required is not a valid access command #692

Closed
karlhorky opened this issue Apr 11, 2023 · 7 comments · Fixed by #693
Closed

Error with npm v9+: npm access 2fa-required is not a valid access command #692

karlhorky opened this issue Apr 11, 2023 · 7 comments · Fixed by #693

Comments

@karlhorky
Copy link
Contributor

karlhorky commented Apr 11, 2023

Description

Publishing a package for the first time causes an error with npm access:

$ npm --version
9.3.1
$ np --version
7.7.0
$ np --yolo

...

  ✔ Prerequisite check
  ✔ Git
  ✔ Bumping version using npm
  ✔ Publishing package using npm
  ✖ Enabling two-factor authentication
  ✖ Enabling two-factor authentication
    → npm ERR!     /Users/k/.npm/_logs/2023-04-11T16_44_52_318Z-debug-0.log
    Pushing tags
    Creating release draft on GitHub

✖ Command failed with exit code 1: npm access 2fa-required <pkg-name> --otp <otp value>
npm ERR! code EUSAGE
npm ERR! 
npm ERR! 2fa-required is not a valid access command
npm ERR! 
npm ERR! Set access level on published packages
npm ERR! 
npm ERR! Usage:
npm ERR! npm access list packages [<user>|<scope>|<scope:team> [<package>]
npm ERR! npm access list collaborators [<package> [<user>]]
npm ERR! npm access get status [<package>]
npm ERR! npm access set status=public|private [<package>]
npm ERR! npm access set mfa=none|publish|automation [<package>]
npm ERR! npm access grant <read-only|read-write> <scope:team> [<package>]
npm ERR! npm access revoke <scope:team> [<package>]
npm ERR! 
npm ERR! Options:
npm ERR! [--json] [--otp <otp>] [--registry <registry>]
npm ERR! 
npm ERR! Run "npm help access" for more info

npm access 2fa-required was a command in npm@8:

Screenshot 2023-04-11 at 18 52 27

The npm access 2fa-required command seems to be gone from the npm@9 docs:

Screenshot 2023-04-11 at 18 52 41

Steps to reproduce

  1. Publish a package for the first time using npm v9+
  2. 💥 See the error

Expected behavior

No errors when publishing a package for the first time with npm v9+

Environment

np - 7.7.0
Node.js - 18.14.1
npm - 9.3.1
Git - 2.39.2
OS - macOS 13.3.1

Workaround

Downgrade npm to v8:

npm install --global npm@^8

cc @DerTimonius in case you want to do another PR :)

@tommy-mitchell
Copy link
Collaborator

Seems like all of the npm access commands were changed in v9: npm docs

I believe the new command should be npm access set mfa publish (libnpmaccess docs)

@DerTimonius
Copy link
Contributor

I would like to take a look at this 🙂

@DerTimonius
Copy link
Contributor

Opened a PR here #693

@karlhorky
Copy link
Contributor Author

Thanks for the PR @DerTimonius and for the review and merge @sindresorhus ! I'm guessing this will be released soon in [email protected] or [email protected]?

@karlhorky
Copy link
Contributor Author

@sindresorhus would it be possible to get a new version of np published with this change?

@sindresorhus
Copy link
Owner

https://github.com/sindresorhus/np/releases/tag/v8.0.0

@karlhorky
Copy link
Contributor Author

Great, thanks! 🙌

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

Successfully merging a pull request may close this issue.

4 participants