Automatically complete npm OTP 2FA.
npm install -D unotp- Install the 1Password CLI.
- Set the
UNOTP_1PASSWORD_KEYenvironment variable to the name of your npm item in 1Password, or useop items listto find the item ID.
You can add this setting to your shell profile for convenience.
export UNOTP_1PASSWORD_KEY=npmset -gx UNOTP_1PASSWORD_KEY npmYou can also use a custom command to retrieve the OTP. Set the UNOTP_CUSTOM_CMD environment variable to your command.
export UNOTP_CUSTOM_CMD="echo 123456"npx unotp <command>
# Example:
npx unotp npm publish{
"scripts": {
"release": "unotp npm publish"
}
}MIT License © 2025 Kevin Deng