nvm icon indicating copy to clipboard operation
nvm copied to clipboard

nvm ins not compatible with replace-registry-host config option

Open nkonevich opened this issue 2 years ago • 4 comments
trafficstars

Operating system and version:

Ubuntu-20.04

nvm debug output:

nvm --version: v0.39.3
$SHELL: /bin/bash
$SHLVL: 1
whoami: 'root'
${HOME}: /root
${NVM_DIR}: '/usr/local/lib/nvm'
${PATH}: ${NVM_DIR}/versions/node/v18.2.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/lib/sonar-scanner-cli/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: 'https://.../artifactory/node-dist-remote'
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)'
uname -a: 'Linux 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux'
checksum binary: 'sha256sum'
OS version: Ubuntu 20.04.6 LTS  
random-funcs:       srandom/random
regex-funcs:        internal
compiled limits:
sprintf buffer      8192
maximum-integer     2147483647
awk: /usr/bin/awk, mawk 1.3.4 20200120
curl: /usr/bin/curl, curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3
wget: /usr/bin/wget, GNU Wget 1.20.3 built on linux-gnu.
git: /usr/bin/git, git version 2.25.1
grep: /usr/bin/grep (grep --color=auto), grep (GNU grep) 3.4
sed: /usr/bin/sed, sed (GNU sed) 4.7
cut: /usr/bin/cut, cut (GNU coreutils) 8.30
basename: /usr/bin/basename, basename (GNU coreutils) 8.30
rm: /usr/bin/rm, rm (GNU coreutils) 8.30
mkdir: /usr/bin/mkdir, mkdir (GNU coreutils) 8.30
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.7.0
nvm current: v18.2.0
which node: ${NVM_DIR}/versions/node/v18.2.0/bin/node
which iojs: 
which npm: ${NVM_DIR}/versions/node/v18.2.0/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v18.2.0
npm root -g: ${NVM_DIR}/versions/node/v18.2.0/lib/node_modules

nvm ls output:

       v14.19.3
       v16.15.0
->      v18.2.0
default -> 18 (-> v18.2.0)

How did you install nvm?

Manual installation

env

NVM_DIR="/usr/local/lib/nvm"
ENV BASH_ENV="/etc/bash-custom.bashrc"

/etc/bash-custom.bashrc

[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

What steps did you perform?

  • generate package-lock.json using "npm install" ant simple package.json example.
  • in .npmrc define a private repository
  • in .npmrc set replace-registry-host=never By default, npm replaces package URLs from registry.npmjs.org to the configured repository.
  • execute npm ci
package.json
{
  "name": "demo-arti-authentication-npm",
  "version": "0.0.0",
  "private": true,
  "dependencies": {
    "@angular/animations": "^13.0.2"
  }
}
.npmrc
registry=https://.../artifactory/api/npm/npm-remote/
replace-registry-host=never

What happened?

npm replaces the resolved URLs with the configured registry even if the replace-registry-host option is set to "never".

What did you expect to happen?

With the replace-registry-host=never I want npm to keep the original URLs. This is needed to ensure that my GitLab pipelines(behind a proxy without direct access to "registry.npmjs.org") will fail if a developer commits a package-lock.json with resolved URLs that include "registry.npmjs.org". If I try to do the same with an npm, that was installed directly (without nvm), it works without problems.

nkonevich avatar Jul 05 '23 11:07 nkonevich

I'm not sure why using nvm would affect this.

What do you mean installed directly? npm should never be installed by itself, it only ever comes with node.

ljharb avatar Jul 05 '23 16:07 ljharb

I'm not sure why using nvm would affect this.

What do you mean installed directly? npm should never be installed by itself, it only ever comes with node.

  • I can not say for sure that the problem lies on nvm, but I have this problem only when node is installed via nvm. I tested it a lot and came to this assumption. With the ticket I was hoping, that you could at least give me a hint where to look, maybe I missed something during the vnm install.
  • with "installed directly", I meant together with node (via 'apt' from Ubuntu repository)

I will check the issue again this week and will add a comment if I find any additional information. It would be great if the problem was solvable so I can use the nvm.

nkonevich avatar Jul 11 '23 08:07 nkonevich

Definitely do not ever install node from apt, it's broken. I'd suggest fully removing anything node or npm you installed from apt.

ljharb avatar Jul 11 '23 12:07 ljharb

Closing for lack of followup.

ljharb avatar Jun 10 '24 06:06 ljharb