-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Problem
NPM package can't be published with publib when 2FA is configured in the target NPM account.
Details
npm publish command used in publib-npm (source) requires an --opt flag when 2FA is configured. There's no equivalent env variable according to NPM docs.
Workaround
I was able to publish an NPM package by editing publib sources in node_modules. I added the --otp flag in node_modules/.bin/publib-npm:
npm publish ${tag} ${access} ${file} --otp <my_temp_code> 2>&1 | tee ${log}Suggested Solution
An NPM_OTP_TOKEN env variable could be supported by publib and used as the --otp flag value in the npm publish command. This won't be the optimal solution, though, as the OTP token is short-lived and will have to be updated right before running the publib command. A better solution would be to somehow allow npm publish to run in interactive mode and prompt the user for the OTP token. (see NPM OTP option docs).