Artifactory npm repository verify username and password - npm

I have created a npm virtual repo in artifactory. And i can publish after i npm login.
But when i use npm install command, it will show 403 which means must npm login first.
So how to let artifactory not check the username & password for npm repository?

Maybe off topic, but you may run npm install with JFrog CLI and it does all of the authentication for you.
This can be acheived in two steps:
Configure Artifactory server: jfrog rt c rt-server-1
Run npm install: jfrog rt npm-install [your-virtual-repo]

Related

Mirror npm repository

I have a non-internet network and I need npm to develop my application.
How could I mirror all the npm packages offline and then use it?
I've found Verdaccio for the private publish. I need a way to replicate the npm repository.

Publish npm package to gitlab registry

I am trying to publish a package to a private Gitlab npm registry. I am following gitlab's docs on how to do this, but something isn't working right.
First, I created a personal access token with all access. Then, in my terminal, as per their docs, I set
npm config set #myproject/my_package http://gitlab.com/api/v4/projects/myproject/my_package/packages/npm/
npm config set -- http://gitlab.com/api/v4/projects/myproject/my_package/packages/npm/:_authToken "<my_token>"
Though there is no output from these commands, so I'm not really sure what its doing or if its working as intended.
Next, in my package.json, I set the name and publishConfig to what you would expect for a scoped package:
{
"name": "#myproject/my_package",
"publishConfig": {
"access": "restricted",
"#myproject/my_package": "https://gitlab.com/af56/myproject/my_package/packages/npm/"
}
}
I then run npm publish. I see that the package is being built, but then I get an error
npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https://registry.npmjs.org/npm ERR!
need auth You need to authorize this machine using `npm adduser`
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\me\AppData\Local\npm-cache\_logs\2022-11-09T00_00_38_418Z-debug-0.log
I don't understand why npm is trying to reach npmjs when I configured it to use gitlab as the registery, both through the command line, and in the package.json. I've published packages to npmjs before, but never to gitlab registry, so I'm not sure what steps I'm missing / doing wrong.

How would you execute npm install with a specific version from the nexus repo

How to execute npm install with a specific version from the nexus repo?
My artifacts are stored in Nexus. what I need to do is execute npm install <nexus version>. However when I do this it still uses my latest package.json that I committed. I want to use all artifacts including package.json from the version in my nexus repo.
Using npm via NXRM behaves the same as using npm without NXRM as far as installs go. You can use npm install package#version.
So for example, npm install pluto#0.4.0.
See npm install doc for more details.

Import a private repository from linux

The code below works fine with Windows with the command mpm i.
"dependencies": {
"my-pack": "git+https://myprivategit.com/my/repo#v0.1.0"
},
A credential form standard of windows is open, and the login and password is passed.
But on Linux an authetication error is returned.
npm install
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t https://myprivategit.com/my/repo
npm ERR!
npm ERR! remote: HTTP Basic: Access denied
npm ERR! fatal: Authentication failed for 'https://myprivategit.com/my/repo.git/'
npm ERR!
npm ERR! exited with error code: 128
Looks like you need to add your credentials, can you try the following:
Generate an access token for the repository you wish to npm install from. For example, go here to create an access token.
Prefix your GIT Repo within your package.json to use the access token generated from step 1:
"dependencies": {
"my-pack": "git+https://<token>:x-oauth-basic#github.com/<user>/myprivategit.com/my/repo#v0.1.0"
},
or:
Create a .netrc within your home directory and give it the necessary credentials to login:
touch ~/.netrc
.netrc:
machine github.com login <token>
then just leave the url to your private repo as is within your .package.json
What worked for me was to do the npm install together with my ssh key stored in .ssh.
npm install git+ssh://git#your_git_server.com:your_username/your_private_repo_name.git
I followed this tutorial.

Not able to download npm packages from corporate nexus repository?

I'm behind a company proxy and trying to access npm packages from nexus repository hosted on the same proxy. I can login to the nexus repository from browser using the same username and password but not through npm cli
Here is what my .npmrc file looks like
http-proxy=http://username:password#companyproxy.com:8080
https-proxy=http://username:password#companyproxy.com:8080/
email=email#companyproxy.com
always-auth=true
registry=http://customrepository.com
strict-ssl=false
no_proxy=.companyproxy.com
_auth="someauthtoken"
Here is the error i'm getting:
npm install -g #angular/cli
npm ERR! code E401
npm ERR! 404 401 Unauthorized: #angular/cli#latest
As it turns out, the issue was regarding authentication. I was passing the incorrect auth token all along.
Worked fine as soon as the correct token was passed.