Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
63c2c73d
Commit
63c2c73d
authored
Sep 19, 2019
by
James Tharpe
Committed by
Achilleas Pipinellis
Sep 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix instructions regarding `npm publish` registry
parent
ba1c2b3e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
0 deletions
+48
-0
doc/user/packages/npm_registry/index.md
doc/user/packages/npm_registry/index.md
+48
-0
No files found.
doc/user/packages/npm_registry/index.md
View file @
63c2c73d
...
@@ -84,6 +84,28 @@ NOTE: **Note:**
...
@@ -84,6 +84,28 @@ NOTE: **Note:**
If you encounter an error message with
[
Yarn
](
https://yarnpkg.com/en/
)
, see the
If you encounter an error message with
[
Yarn
](
https://yarnpkg.com/en/
)
, see the
[
troubleshooting section
](
#troubleshooting
)
.
[
troubleshooting section
](
#troubleshooting
)
.
### Using variables to avoid hard-coding auth token values
To avoid hard-coding the
`authToken`
value, you may use a variables in its place.
In your
`.npmrc`
file, you would add:
```
ini
@foo:
registry
=
https://gitlab.com/api/v4/packages/npm/
//gitlab.com/api/v4/packages/npm/:
_authToken
=
${NPM_TOKEN}
//gitlab.com/api/v4/projects/<your_project_id>/packages/npm/:
_authToken
=
${NPM_TOKEN}
```
Then, you could run
`npm publish`
either locally or via GitLab CI/CD:
-
**Locally:**
Export
`NPM_TOKEN`
before publishing:
```
sh
NPM_TOKEN
=
<your_token> npm publish
```
-
**GitLab CI/CD:**
Set an
`NPM_TOKEN`
[
variable
](
../../../ci/variables/README.md
)
under your project's
**Settings > CI/CD > Variables**
.
## Uploading packages
## Uploading packages
Before you will be able to upload a package, you need to specify the registry
Before you will be able to upload a package, you need to specify the registry
...
@@ -145,3 +167,29 @@ with your with your OAuth or personal access token):
...
@@ -145,3 +167,29 @@ with your with your OAuth or personal access token):
```
text
```
text
//gitlab.com/api/v4/projects/:_authToken=<your_oauth_token>
//gitlab.com/api/v4/projects/:_authToken=<your_oauth_token>
```
```
### `npm publish` targets default NPM registry (`registry.npmjs.org`)
Ensure that your package scope is set consistently in your
`package.json`
and
`.npmrc`
files.
For example, if your project name in GitLab is
`foo/my-package`
, then your
`package.json`
file
should look like:
```
json
{
"name"
:
"@foo/my-package"
,
"version"
:
"1.0.0"
,
"description"
:
"Example package for GitLab NPM registry"
,
"publishConfig"
:
{
"@foo:registry"
:
"https://gitlab.com/api/v4/projects/<your_project_id>/packages/npm/"
}
}
```
And the
`.npmrc`
file should look like:
```
ini
//gitlab.com/api/v4/projects/<your_project_id>/packages/npm/:
_authToken
=
<your_oauth_token>
//gitlab.com/api/v4/packages/npm/:
_authToken
=
<your_oauth_token>
@foo:
registry
=
https://gitlab.com/api/v4/packages/npm/
```
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment