np icon indicating copy to clipboard operation
np copied to clipboard

User authentication fails

Open bennycode opened this issue 5 years ago • 5 comments

Description

I ran "np" but it failed telling me "You must be logged in. Use npm login and try again.". I executed "npm whoami" and saw that I am already logged in. So there seems to be a bug.

Steps to reproduce

  1. Use a scoped package
  2. Add "release": "np" to your "scripts" section in "package.json"
  3. Run "yarn release"

.np-config.json

{
  "anyBranch": false,
  "cleanup": true,
  "contents": "proto",
  "preview": true,
  "tests": true,
  "yarn": true
}

Expected behavior

"Verify user is authenticated" to not fail.

Environment

np - 6.2.0 Node.js - 12.11.0 npm - 6.10.1 Git - 2.16.2.windows.1 OS - Windows 10

bennycode avatar Feb 27 '20 09:02 bennycode

I added a script to my package that runs npm whoami. Running that via yarn fails as well; this does not appear to be specific to np.

package.json:

  ...
  "scripts": {
    "test-who": "npm whoami"
  }

running via npm

mlclay@gram:~/projects/sandbox$ npm whoami
mlclay

running via yarn

mlclay@gram:~/projects/sandbox$ yarn test-who
yarn run v1.17.3
$ npm whoami
npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in.
npm ERR! need auth You need to authorize this machine using `npm adduser`

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/lucas/.npm/_logs/2020-03-11T15_03_49_396Z-debug.log
error Command failed with exit code 1.

Update

While writing this, I came across the yarn login command. https://classic.yarnpkg.com/en/docs/cli/login/

After I ran yarn login and entered my username/email, then my subsequent yarn test-who and yarn np commands worked without the authentication issue we ran in to.

mlclay@gram:~/projects/sandbox$ yarn test-who
yarn run v1.17.3
$ npm whoami
mlclay

mlclay avatar Mar 11 '20 15:03 mlclay

The @mlclay's method also helped me

andywampir avatar Mar 12 '20 17:03 andywampir

@mlclay method worked for me as well

niconiahi avatar Sep 20 '20 01:09 niconiahi

@mlclay's workaround didn't worked for me :slightly_frowning_face: But npx np did

Shinigami92 avatar Mar 25 '21 18:03 Shinigami92

I am having the same issue.

I have np installed globally.

I run:

npm login                                                                                                                                                           
Username: elaniobro
Password:
Email: (this IS public) [email protected]
npm notice Please use the one-time password (OTP) from your authenticator application
Enter one-time password from your authenticator app: ######
Logged in as elaniobro on https://registry.npmjs.org/
np                                                                                                                                                                  

Warning: No files field specified in package.json nor is a .npmignore file present. Having one of those will prevent you from accidentally publishing development-specific files along with your package's source code to npm.


Publish a new version of mmm-nyc-transit (current: 4.2.0)

Commits:
- docs: add joolean as a contributor for bug, code (#65)  9db9908
- Fix reversed upTown and downTown arrival filtering (#64)  866a181
- Support multiple instances of MMM-nyc-transit with different configurations (#62)  2c5668a
- Update .all-contributorsrc  b03645e

Commit Range:
v4.2.1...master

Registry:
https://npm.pkg.github.com/elaniobro/MMM-nyc-transit

? Select semver increment or specify new version minor 	4.3.0

  ❯ Prerequisite check
    ✔ Check npm version
    ✔ Check yarn version
    ✖ Verify user is authenticated
      → You must be logged in. Use `npm login` and try again.
      Check git version
      Check git remote
      Validate version
      Check for pre-release version
      Check git tag existence
    Git
    Installing dependencies using Yarn
    Running tests using Yarn
    Bumping version using Yarn
    Publishing package using Yarn
    Pushing tags
    Creating release draft on GitHub

✖ You must be logged in. Use `npm login` and try again.

Aborted!

It is still failing for me, even after logging into npm. Perhaps I am doing something wrong is there a flag to use for login with np that is not documented? FWIW I also mainly use yarn.

Elaniobro avatar Dec 16 '21 15:12 Elaniobro