Nvm: gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR

Created on 15 Mar 2017  路  6Comments  路  Source: nvm-sh/nvm

  • Operating system and version:

```$ uname -a
Linux i3 4.4.0-66-generic #87-Ubuntu SMP Fri Mar 3 15:29:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

- `nvm debug` output:
<details>
<!-- do not delete the following blank line -->

```sh
nvm --version: v0.32.0
$SHELL: /bin/bash
$HOME: /home/mrm
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: v7.7.1
which node: $NVM_DIR/versions/node/v7.7.1/bin/node
which iojs:
which npm: $NVM_DIR/versions/node/v7.7.1/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v7.7.1
npm root -g: $NVM_DIR/versions/node/v7.7.1/lib/node_modules

  • nvm ls output:

$ nvm ls
        v5.12.0
         v6.2.2
         v6.5.0
         v6.8.0
         v7.6.0
->       v7.7.1
default -> node (-> v7.7.1)
node -> stable (-> v7.7.1) (default)
stable -> 7.7 (-> v7.7.1) (default)
iojs -> N/A (default)
lts/* -> lts/argon (-> N/A)
lts/argon -> v4.8.0 (-> N/A)
lts/boron -> v6.10.0 (-> N/A)

  • How did you install nvm?
    install script in readme

  • What steps did you perform?
    Building native npm dependencies

  • What happened?

gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
  • What did you expect to happen?
    No warnings

  • Is there anything in any of your profile files (.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH?
    Yes, but that's irrelevant here.

驴por qu茅 no los dos?

I don't know how many other systems look at these variables, so the safest (and most-chicken^H^H^H^H^H^Hconservative) solution would be to set both MIRROR values with and without the NPM prefix. The following, added to my ~/.bashrc after the call to source nvm.sh, removes the node-gyp warning:

export NODEJS_ORG_MIRROR=${NODEJS_ORG_MIRROR-$NVM_NODEJS_ORG_MIRROR}
export IOJS_ORG_MIRROR=${IOJS_ORG_MIRROR-$NVM_IOJS_ORG_MIRROR}

FWIW, I didn't have to unset NVM_NODEJS_ORG_MIRROR. Having both set seems harmless.

pull request wanted

Most helpful comment

Thanks, that's totally reasonable, and just what I had in mind :-) Want to submit a PR (with unit test)? :-D

All 6 comments

Sure, having both set is harmless, and nvm will indeed always set $NVM_NODEJS_ORG_MIRROR for you.

node-gyp is the only software I'm aware of that incorrectly depended on nvm's env vars - it no longer does, hence the warning.

Are you suggesting that nvm add support for $NODEJS_ORG_MIRROR as well? I'm a bit hesitant to add more env var complexity, and to shackle nvm's internal configuration to something other tools depend on (which is why I recommended node-gyp migrate to a separate env var in the first place).

OK. In that case, perhaps the workaround should be:

unset NVM_IOJS_ORG_MIRROR NVM_NODEJS_ORG_MIRROR

I don't know how clever you want to make nvm.sh, but perhaps if node-gyp is a recent-enough version, it could avoid setting the variable in the first place?

I guess a totally reasonable alternative would be, making nvm no longer create these env vars unconditionally - ie, use them if present, fall back to the defaults if not. That should avoid the node-gyp warning in the most scenarios, while also reducing the env var pollution from nvm?

defaults, fwiw, are super easy, and cross-shell-compatible. You'd just delete this:

# Setup mirror location if not already set
if [ -z "${NVM_NODEJS_ORG_MIRROR-}" ]; then
  export NVM_NODEJS_ORG_MIRROR="https://nodejs.org/dist"
fi

if [ -z "${NVM_IOJS_ORG_MIRROR-}" ]; then
  export NVM_IOJS_ORG_MIRROR="https://iojs.org/dist"
fi

and update nvm_get_mirror with the default URLs:

nvm_get_mirror() {
  case "${1}-${2}" in
    node-std) nvm_echo "${NVM_NODEJS_ORG_MIRROR:-https://nodejs.org/dist}" ;;
    iojs-std) nvm_echo "${NVM_IOJS_ORG_MIRROR:-https://iojs.org/dist}" ;;
    *)
      nvm_err 'unknown type of node.js or io.js release'
      return 1
    ;;
  esac
}

(If this is reasonable I can give you a PR so you can goose your Contributors count)

Thanks, that's totally reasonable, and just what I had in mind :-) Want to submit a PR (with unit test)? :-D

omg hour builds I'm getting monorail flashbacks

Was this page helpful?
0 / 5 - 0 ratings