我创建了一个经典的 js 包,并添加了 NP 来管理发布流程,但由于某种原因,当我执行
npm run np
命令时,出现以下错误:
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`
但是我已经登录了,如果我执行
npm publish
,它会完美运行
这对原始海报没有帮助,但对于其他偶然发现此问题并使用
yarn
启动 np
脚本的人,请尝试使用 npm run
代替。这是我遇到的问题,使用 npm run
解决了它。
所以,例如:
# not this
yarn release
# but this instead
npm run release
(假设您的发布脚本名为
release
。)
我设法解决了我的问题。
我从依赖项列表中删除了
np
并安装了它 全局
然后使用我使用的任何包管理器,它都工作得很好。
这是我的 package.json 脚本的样子:
// ...
"scripts": {
"release": "npm run prepare && np"
}
# whit yarn
yarn run release
# whit npm
npm run release
# whit pnpm
pnpm run release