3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

npmでorgにパッケージをpublishする時にちょっとハマった

Posted at

今日はじめてorgでパッケージ公開しようとしてちょっとハマったやつ

普通にnpm loginしてpublicでscoped packageをpublishしようと以下を実行したらエラーがでた

npm publish --access public

エラー

npm ERR! code E403
npm ERR! 403 403 Forbidden - PUT https://npm.pkg.github.com/@org-name/package-name - Permission permission_denied: The token provided does not match expected scopes.
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy, or
npm ERR! 403 on a server you do not have access to.

npm ERR! A complete log of this run can be found in: /Users/xxxxx/.npm/_logs/xxxx-debug-0.log

loginアカウントはorgに所属していてmember権限を持ってたので公開できるはずじゃん、なんで...ってなってpublishとかloginコマンドのhelp見てたら以下を発見した

$ npm help login
...
   scope

       •   Default: the scope of the current project, if any, or ""

       •   Type: String


       Associate an operation with a scope for a scoped registry.

       Useful when logging in to or out of a private registry:

         # log in, linking the scope to the custom registry
         npm login --scope=@mycorp --registry=https://registry.mycorp.com

         # log out, removing the link and the auth token
         npm logout --scope=@mycorp

       This will cause @mycorp to be mapped to the registry for future installation of packages specified according to the pattern @mycorp/package.

       This will also cause npm init to create a scoped package.

         # accept all defaults, and create a package named "@foo/whatever",
         # instead of just named "whatever"
         npm init --scope=@foo --yes

ログインの時にスコープ指定できるらしい。

確かに1つのアカウントが複数のorgと紐づいてることもあるし、どのorgのレジストリにpublishするか知る必要あるのであたりまえといえばあたりまえだった。

なぜか見つけるまで気づかなかったが

というわけでログインをやり直して無事解決した

npm login --scope=@org-name
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?