[英]How to publish my npm package in GitLab NPM Registry?
I hooked up a trial gold plan to test GitLab NPM Registry functionality.我制定了一个试用黄金计划来测试 GitLab NPM Registry 功能。
Created a file to generate a token: in the file with the name auth.txt I wrote the line: grant_type=password&username=my-gitlab-username& password=my-gitlab-password
创建了一个文件来生成一个令牌:在名为 auth.txt 的文件中我写了一行: grant_type=password&username=my-gitlab-username& password=my-gitlab-password
Generated a token using the command: curl -d "@ auth.txt" -X POST http:/gitlab.com/oauth/token
使用命令生成令牌: curl -d "@ auth.txt" -X POST http:/gitlab.com/oauth/token
gitlab.com/api/v4/projects/my-gitlab-project-id/packages/npm/:_ authToken=my-genereated-token
在 .npmrc 文件中,路径表示为gitlab.com/api/v4/projects/my-gitlab-project-id/packages/npm/:_ authToken=my-genereated-token
console.log('test')
创建了一个用于测试的 app.js 文件,内容为: console.log('test')
{
"name": "@foo/bar",
"version": "1.0.0",
"description": "",
"main": "app.js",
"dependencies": {
"express": "^4.16.4"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js"
},
"author": "",
"license": "ISC",
"publishConfig": {
"registry":"http://gitlab.com/api/v4/projects/my-gitlab-project-id/packages/npm/"
}
}
6.In the folder now there are 3 files: 6.文件夹里现在有3个文件:
.npmrc
app.js
package.json
npm --verbose publish
npm verb cli [ '/usr/bin/node', '/usr/local/bin/npm', '--verbose', 'publish' ]
npm info using npm@6.14.2
npm info using node@v13.11.0
npm verb npm-session febf284b8dfbe40b
npm verb publish [ '.' ]
npm info lifecycle @foo/bar@1.0.0~prepublish: @foo/bar@1.0.0
npm info lifecycle @foo/bar@1.0.0~prepare: @foo/bar@1.0.0
npm info lifecycle @foo/bar@1.0.0~prepublishOnly: @foo/bar@1.0.0
npm info lifecycle @foo/bar@1.0.0~prepack: @foo/bar@1.0.0
npm info lifecycle @foo/bar@1.0.0~postpack: @foo/bar@1.0.0
npm notice
npm notice 📦 @foo/bar@1.0.0
npm notice === Tarball Contents ===
npm notice 687B logs
npm notice 175B app.js
npm notice 404B package.json
npm notice 582B README.md
npm notice 55B auth.loc.txt
npm notice 59B auth.txt
npm notice === Tarball Details ===
npm notice name: @foo/bar
npm notice version: 1.0.0
npm notice package size: 1.1 kB
npm notice unpacked size: 2.0 kB
npm notice shasum: c4220955014b80c6948ff2a20124ac8d145d0675
npm notice integrity: sha512-pOQJVaXuneH80[...]DdtCjSLD1vkDQ==
npm notice total files: 6
npm notice
npm http fetch PUT 301 http://gitlab.com/api/v4/projects/my-gitlab-project-id/packages/npm/@foo%2fbar 283ms
npm info lifecycle @foo/bar@1.0.0~publish: @foo/bar@1.0.0
npm info lifecycle @foo/bar@1.0.0~postpublish: @foo/bar@1.0.0
@foo/bar@1.0.0
npm verb exit [ 0, true ]
npm timing npm Completed in 555ms
npm info ok
Packages > List
not a single package is displayed, either in the All section or in the NPM section.但是在左侧列表的 GitLab 中 - 在Packages > List
,无论是在 All 部分还是在 NPM 部分,都没有显示单个包。Please help me figure out what I'm doing wrong.请帮我弄清楚我做错了什么。
You can try to specify the package registry for the exact project.您可以尝试为确切的项目指定包注册表。
.npmrc file example: .npmrc 文件示例:
# Set URL for your scoped packages.
@foo:registry=https://gitlab.com/api/v4/projects/<Source Project ID>/packages/npm/
# Add the token for the scoped packages URL. This will allow you to download
//gitlab.com/api/v4/projects/<Source Project ID>/packages/npm/:_authToken=${CI_JOB_TOKEN}
# with the project you want your package to be uploaded to.
//gitlab.com/api/v4/projects/<Destination Project ID>/packages/npm/:_authToken=${CI_JOB_TOKEN}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.