{
    "componentChunkName": "component---src-templates-blog-post-jsx",
    "path": "/post/how-to-publish-npm-public-scoped-package-with-lerna/",
    "result": {"data":{"site":{"siteMetadata":{"title":"WEB EGG","author":"Leko - CTO at Yuimedi"}},"markdownRemark":{"id":"390ab137-19c6-5838-8b16-37495f784644","excerpt":"hothouseという、package.jsonを更新してPRを作成するGreenkeeperのようなOSSを作る際に、 プラグイン開発用の内部I/Fを@hothouse/typesというpublicなパッケージとしてpublishしようとしたところ、失敗しました。 公開する時はnpm publish —access…","html":"<p><a href=\"https://github.com/Leko/hothouse\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">hothouse</a>という、package.jsonを更新してPRを作成するGreenkeeperのようなOSSを作る際に、<br>\nプラグイン開発用の内部I/Fを<code>@hothouse/types</code>というpublicなパッケージとしてpublishしようとしたところ、失敗しました。</p>\n<blockquote>\n<p>公開する時はnpm publish —access=publicとするだけです。(デフォルトが—access=restrictedであるため明示する必要がある)</p>\n<p>— <a href=\"https://efcl.info/2015/04/30/npm-namespace/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">npmで名前空間を持ったモジュールを公開する方法(scoped modules) | Web Scratch</a></p>\n</blockquote>\n<p>単一のnpm packageなら<code>--access</code>をつければ良いのですが、（少なくとも2.11.0時点で）lernaでpublishする際に<code>--access</code>を指定できる余地がない。<br>\nということで調べてみました。</p>\n<!--more-->\n<h2 id=\"対応策\" style=\"position:relative;\"><a href=\"#%E5%AF%BE%E5%BF%9C%E7%AD%96\" aria-label=\"対応策 permalink\" class=\"autolink-header before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>対応策</h2>\n<blockquote>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token string\">\"publishConfig\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token string\">\"access\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"public\"</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>— <a href=\"https://github.com/lerna/lerna/issues/914#issuecomment-318497928\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">No docs on how to publish public scoped packages · Issue #914 · lerna/lerna</a></p>\n</blockquote>\n<p>LernaのIssueにこんなコメントがついており、試してみたところ無事publishできました。</p>\n<h2 id=\"publishconfigとはなんなのか\" style=\"position:relative;\"><a href=\"#publishconfig%E3%81%A8%E3%81%AF%E3%81%AA%E3%82%93%E3%81%AA%E3%81%AE%E3%81%8B\" aria-label=\"publishconfigとはなんなのか permalink\" class=\"autolink-header before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>publishConfigとはなんなのか</h2>\n<blockquote>\n<p>This is a set of config values that will be used at publish-time. It’s especially handy if you want to set the tag, registry or access, so that you can ensure that a given package is not tagged with “latest”, <strong>published to the global public registry or that a scoped module is private by default</strong>.\nAny config values can be overridden, but only “tag”, “registry” and “access” probably matter for the purposes of publishing.</p>\n<p>— <a href=\"https://docs.npmjs.com/files/package.json#publishconfig\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">package.json | npm Documentation</a></p>\n</blockquote>\n<p>その名の通り、publishするときの設定を指定するためのフィールドです。<br>\n<code>access</code>フィールドに値を指定すれば、publish時のアクセス設定を変更できるということでした。</p>\n<p>lernaの仕様ではなく、npmの仕様だったので、このオプションを安心して使用できます。</p>","timeToRead":2,"frontmatter":{"title":"lernaでnpmにpublicなscoped packageをpublishする方法","tags":["JavaScript","npm"],"date":"July 03, 2018","featuredImage":null}}},"pageContext":{"slug":"/how-to-publish-npm-public-scoped-package-with-lerna/","previous":{"fields":{"slug":"/more-easy-to-use-npm-scripts/"},"frontmatter":{"title":"タブ補完でpecoでnpm-scriptsをもっと超簡単に実行したい","tags":["npm","Bash","peco"]}},"next":{"fields":{"slug":"/what-about-hothouse/"},"frontmatter":{"title":"package.jsonを更新してPRを作成できるCLIツールhothouseを作った","tags":["npm","JavaScript"]}}}},
    "staticQueryHashes": ["2585454260","2954598359"]}