Search code examples
node.jsnpmnp

Getting error: "You must be logged in. Use `npm login` and try again." when trying to publish with NP


I have a classic js package that I created and I added NP to manage the publishment flow, but for some reason when I execute npm run np command, I'm getting the following error:

npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https://registry.yarnpkg.com
npm ERR! need auth You need to authorize this machine using `npm adduser`

But I'm already signed in and if I execute npm publish it works perfectly


Solution

  • I managed to solve my issue.

    I removed np from my dependencies list and installed it globally

    Then with any package manager I used, it worked fine.

    Here's what my package.json script looks like:

    // ...
    "scripts": {
      "release": "npm run prepare && np"
    }
    
    # whit yarn
    yarn run release
    
    # whit npm
    npm run release
    
    # whit pnpm
    pnpm run release