[英]How do you publish and install a private npm package to GitHub packages as an organisation?
We have a monorepo with a shared package called "@myorganization/common", that is used by both the app and Google cloud functions.我们有一个名为“@myorganization/common”的共享 package 的 monorepo,应用程序和 Google 云功能都使用它。
Google cloud functions requires that the package is published to a repo to use it, since we do not publish compiled code, that can include local packages, but directly the raw TypeScript.谷歌云功能要求将 package 发布到 repo 才能使用它,因为我们不发布编译代码,可以包含本地包,而是直接发布原始 TypeScript。
I found serveral tutorials but not for the use case of combining private packages and organizations.我找到了一些教程,但不是针对组合私有包和组织的用例。
I cd into the packages/common directory.我进入 packages/common 目录。
I added the following lines to my packages.json:我在 packages.json 中添加了以下行:
"publishConfig": { "registry": "https://npm.pkg.github.com/" },
"repository": {
"url": "git@github.myorganization/common.git"
},
I created a personal Auth Token on GitHub with full repo, packages and org rights.我在 GitHub 上创建了一个个人身份验证令牌,具有完整的回购、包和组织权限。
Then I login to my organization:然后我登录到我的组织:
npm login --registry=https://npm.pkg.github.com --scope=@myorganization
Then I hit:然后我打了:
npm publish
I get the following error:我收到以下错误:
npm ERR! code EPRIVATE
npm ERR! This package has been marked as private
npm ERR! Remove the 'private' field from the package.json to publish it.
I want this package to be only usable by organization members.我希望这个 package 仅供组织成员使用。 It shall be both used as a local private package within the lerna monorepo, when used by React Native, and used by Google Cloud Function by getting it from GitHub packages.它应在 lerna monorepo 中用作本地私有 package,当由 React Native 使用时,并由 Google Cloud Function 通过从 GitHub 包中获取它来使用。 Yet no other people shall be able to access it.但是没有其他人可以访问它。
Is it something that is possible?这是可能的吗?
Regards问候
Edit:编辑:
I tried to update packages.json, removing private=true and trying to ensure I publish it to my private organization:我尝试更新 packages.json,删除 private=true 并尝试确保将其发布到我的私人组织:
"publishConfig": {
"registry": "https://npm.pkg.github.com/:_authToken=xxxx --scope=@myorganization"
},
I now get the error:我现在得到错误:
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://npm.pkg.github.com/@myorganization%2fcommon - The expected resource was not found.
npm ERR! 404
npm ERR! 404 '@myorganization/common@0.0.7' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
I was facing the exact same issue.我面临着完全相同的问题。 Here's what worked for me.这对我有用。
I had to create that organization (ie myorganization
in your example) on GitHub and a repo with same name (ie common
in your example) as repo under that organization and it worked.我必须在myorganization
上创建该组织(即您的示例中的 myorganization),并创建一个与该组织下的 repo 名称相同的 repo(即您的示例中的common
)并且它有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.