我正在尝试在 GPR(Github 包注册表)上上传一个包。我登录成功:
npm login --registry=https://npm.pkg.github.com
Run Code Online (Sandbox Code Playgroud)
然后运行这些命令:
npm set registry https://npm.pkg.github.com/
npm publish
Run Code Online (Sandbox Code Playgroud)
返回此错误:
npm ERR! 404 Not Found - PUT https://npm.pkg.github.com/package-name
npm ERR! 404
npm ERR! 404 'package-name@version' is not in the npm registry.
Run Code Online (Sandbox Code Playgroud)
似乎它试图在 npm 注册表而不是 github 包注册表上上传包。我应该如何解决这个问题?
javascript git github github-actions github-package-registry
我创建并发布了一个私有的 Github 包。首先尝试用纱线安装它,我面临以下问题:
无论我尝试使用 yarn 还是 npm,它都无法找到包,尽管遵循 Github 记录的确切步骤(https://help.github.com/en/github/managing-packages-with-github-package-registry/配置 npm-for-use-with-github-package-registry)。
我的.yarnrc:
registry "https://npm.pkg.github.com/OWNER"
使用yarn,它会不断尝试查找包https://registry.yarnpkg.com/@GITHUB_USERNAME而不是我在上面输入的注册表。
备注:在.yarnrc注册表中需要按照稍微不同的语法添加:
registry "https://npm.pkg.github.com/"
到目前为止,我也开始尝试混合.npmrc和.yarnrc配置,但没有运气。
——
编辑(部分解决)
我想出了如何使用 npm 或 - 在我的情况下 - 纱线来实际访问包。现在我遇到了Request failed \"401 Unauthorized\"错误的问题,尽管我在上面添加了凭据.yarnrc:
//npm.pkg.github.com/:_authToken=AUTH_TOKEN
在里面做同样的.npmrc事情也行不通。
我想从公共存储库的 GitHub 操作部署到 GitHub 包注册表。
我有一个用于工作流程的 yml 文件:
name: My CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install dependencies
run: lein deps
- name: Run tests
run: lein test
- name: Generate pom
run: lein pom
- name: Deploy
run: mvn deploy
Run Code Online (Sandbox Code Playgroud)
我使用 Leiningen 来构建项目并生成一个 POM 文件。然后我想使用 Maven 将工件部署到 GitHub 包注册表。
这在Deploy命令上失败(我已用 替换了个人信息...):
[WARNING] Could not transfer metadata ... from/to github (https://maven.pkg.github.com/.../...): Not authorized
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] …Run Code Online (Sandbox Code Playgroud) 这个问题与这些有关。但是没有一个解决方案对我有用。
我可以安装一个没有问题的包,npm install @scope/package但是我不能用纱线做同样的事情:yarn add @scope/package
纱线抛出以下错误:
An unexpected error occurred: "https://npm.pkg.github.com/download/@scope/package/1.2.8/089b08cffb16074c210ec3a59b04de268ae1c7b3a0492dce110adee3ada05bdd: Request failed \"401 Unauthorized\"".
我的 .npmrc 文件看起来像这样:(在 .yarnrc 下尝试和不使用)
registry=https://registry.npmjs.org/
//npm.pkg.github.com/:_authToken=MY_AUTHTOKEN
@scope:registry=https://npm.pkg.github.com/
Run Code Online (Sandbox Code Playgroud)
我试过添加这个 .yarnrc 文件:
registry "https://registry.npmjs.org"
"@scope:registry" "https://npm.pkg.github.com"
Run Code Online (Sandbox Code Playgroud)
(没有 .yarnrc)我试过这个 .npmrc 文件
registry=https://registry.yarnpkg.com/
@scope:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=MY_AUTHTOKEN
always-auth=true
Run Code Online (Sandbox Code Playgroud)
MY_AUTHTOKEN我Personal Access Token从 Github 生成的我在哪里。(它可以访问包中的所有内容)
我试图:
npm login使用我的PAT作为密码yarn login万一出现任何混淆,我实际上并不是在尝试 @scope 和 /package,而是在尝试我的实际作用域和包名称。 …
问题:如何让一个包从 Github 包注册表中“消失”?
背景:
到目前为止的步骤:
curl -X POST \
-H "Accept: application/vnd.github.package-deletes-preview+json" \
-H "Authorization: bearer ACCESS_TOKEN" \
-d '{"query":"mutation { deletePackageVersion(input:{packageVersionId:\"PACKAGE_ID==\"}) { success }}"}' \
https://api.github.com/graphql
Run Code Online (Sandbox Code Playgroud)
curl -X POST \
-H "Accept: application/vnd.github.package-deletes-preview+json" \
-H "Authorization: bearer ACCESS_TOKEN" \
-d "query {
organization(login: "ORGANIZATION_ACCOUNT") {
registryPackages {
edges {
node {
name …Run Code Online (Sandbox Code Playgroud) 当我尝试npm从 GitHub 操作安装我的模块时,我收到以下错误:
npm ERR! 401 Unauthorized - GET https://npm.pkg.github.com/@xxxx%2fxxxx-analytics - Your request could not be authenticated by the GitHub Packages service. Please ensure your access token is valid and has the appropriate scopes configured.
Run Code Online (Sandbox Code Playgroud)
在您发表评论之前,我已经使用范围和访问令牌正确配置了 .npmrc,并且在本地安装私有包时一切正常。
这是我的 GitHub 工作流程操作:
name: JavaScript workflow
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: npmrc
run: cat .npmrc
- name: npm install
run: |
npm install
env: …Run Code Online (Sandbox Code Playgroud) 我可以访问 github 包注册表测试版,只需摆弄它并按照配置步骤进行发布。
问题是,我正确发布了它,但注意到它没有发布到 npm。有没有办法使用相同的命令在两个注册表中发布?在两个注册表中都发布包是否有意义?
此外,我的包名package.json是@alvarocastro/quicksort(如文档中所述)和github 页面中的名称最终是那个,但在要安装的命令示例中,范围是重复的,例如:@alvarocastro/@alvarocastro/quicksort
这是完整的package.json文件作为参考:
{
"name": "@alvarocastro/quicksort",
"version": "1.0.1",
"description": "An implementation of the quicksort algorithm",
"main": "index.js",
"scripts": {
"performance": "node performance.js",
"test": "xo && nyc ava",
"coverage": "nyc report --reporter=text-lcov | coveralls"
},
"publishConfig": {
"registry":"https://npm.pkg.github.com/@alvarocastro"
},
"repository": {
"type": "git",
"url": "git+https://github.com/alvarocastro/quicksort.git"
},
"keywords": [
"quicksort",
"sort",
"algorithm"
],
"author": "Alvaro Castro",
"license": "MIT",
"bugs": {
"url": "https://github.com/alvarocastro/quicksort/issues"
},
"homepage": "https://github.com/alvarocastro/quicksort#readme",
"devDependencies": …Run Code Online (Sandbox Code Playgroud) 我是公共 GitHub 存储库的维护者。我已经设置了 GitHub Actions 来发布到 GitHub 包。您可以在此处看到已创建的包:
https://github.com/paulschwarz/spring-dotenv/packages/135114
我注意到的第一件事是 GitHub 只提供了一个 Maven 安装片段。我使用此代码将依赖项添加到另一个项目,它似乎有效。
现在我想将此包导入到 Gradle 项目中。我加了
dependencies {
implementation ('me.paulschwarz:spring-dotenv:0.0.3')
}
Run Code Online (Sandbox Code Playgroud)
和 gradle 告诉我
Could not find me.paulschwarz:spring-dotenv:0.0.3.
Searched in the following locations:
- https://jcenter.bintray.com/me/paulschwarz/spring-dotenv/0.0.3/spring-dotenv-0.0.3.pom
- https://repo.maven.apache.org/maven2/me/paulschwarz/spring-dotenv/0.0.3/spring-dotenv-0.0.3.pom
Run Code Online (Sandbox Code Playgroud)
这已经很奇怪了,因为我的 Maven 项目在解决依赖项方面似乎没有问题。我必须说我很好奇它是如何工作的?GitHub 包肯定没有与 JCenter 或 Maven Central 集成?
无论如何,下一步,添加存储库
repositories {
jcenter()
mavenCentral()
maven { url = uri('https://maven.pkg.github.com/paulschwarz/spring-dotenv') }
}
Run Code Online (Sandbox Code Playgroud)
此时,Gradle 应该知道在哪里可以找到包。但是,我得到了这个
> Could not resolve me.paulschwarz:spring-dotenv:0.0.3.
> Could not get resource 'https://maven.pkg.github.com/paulschwarz/spring-dotenv/me/paulschwarz/spring-dotenv/0.0.3/spring-dotenv-0.0.3.pom'.
> Could not GET 'https://maven.pkg.github.com/paulschwarz/spring-dotenv/me/paulschwarz/spring-dotenv/0.0.3/spring-dotenv-0.0.3.pom'. Received status code …Run Code Online (Sandbox Code Playgroud) 在与 GitHub 操作一起使用时,我得到了Error response from daemon: Get "https://ghcr.io/v2/": denied: denied
我使用了登录命令echo $CR_PAT | docker login ghcr.io -u $ghcr_user -password-stdin
我正在尝试通过 GitHub 包注册表发布 npm 包,我正在关注文档,当我在输入username和后尝试使用以下命令登录时password(即使两者都是正确的),我总是遇到以下错误。
// Step 2: Authenticate
$ npm login --registry=https://npm.pkg.github.com/
Run Code Online (Sandbox Code Playgroud)
错误日志:
npm login --registry=https://npm.pkg.github.com/
Username: ***********
Password:
Email: (this IS public) *****************
npm ERR! code E401
npm ERR! Registry returned 401 for PUT on https://npm.pkg.github.com/-/user/org.couchdb.user:kgangadhar: Error authenticating user: Bad credentials
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\karth\AppData\Roaming\npm-cache\_logs\2019-10-31T05_35_05_829Z-debug.log
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决它?
npm ×4
github ×3
yarnpkg ×3
maven ×2
docker ×1
ghcr ×1
git ×1
gradle ×1
javascript ×1
node.js ×1
npm-registry ×1
package.json ×1
registry ×1