nvm icon indicating copy to clipboard operation
nvm copied to clipboard

nvm says 'no .nvmrc file found' when the problem is that the version inside of said .nvmrc is not installed.

Open HristoKolev opened this issue 7 years ago • 9 comments

  • Operating system and version: CentOS 7, nvm latest version
  • nvm debug output:
$SHELL: /bin/bash
$HOME: /home/kenny
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)'
uname -a: 'Linux 3.10.0-693.21.1.el7.x86_64 #1 SMP Wed Mar 7 19:03:37 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux'
OS version:
curl: /bin/curl, curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.28.4 zlib/1.2.7 libidn/1.28 libssh2/1.4.3
wget: /bin/wget, GNU Wget 1.14 built on linux-gnu.
git: /bin/git, git version 1.8.3.1
grep: alias grep='grep --color=auto'
        /bin/grep (grep --color=auto), grep (GNU grep) 2.20
awk: /bin/awk, GNU Awk 4.0.2
sed: /bin/sed, sed (GNU sed) 4.2.2
cut: /bin/cut, cut (GNU coreutils) 8.22
basename: /bin/basename, basename (GNU coreutils) 8.22
rm: /bin/rm, rm (GNU coreutils) 8.22
mkdir: /bin/mkdir, mkdir (GNU coreutils) 8.22
xargs: /bin/xargs, xargs (GNU findutils) 4.5.11
nvm current: v9.10.1
which node: $NVM_DIR/versions/node/v9.10.1/bin/node
which iojs: which: no iojs in ($NVM_DIR/versions/node/v9.10.1/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:$HOME/.local/bin:$HOME/bin)
which npm: $NVM_DIR/versions/node/v9.10.1/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v9.10.1
npm root -g: $NVM_DIR/versions/node/v9.10.1/lib/node_modules

  • nvm ls output:
         v9.7.0
->      v9.10.1
default -> node (-> v9.10.1)
node -> stable (-> v9.10.1) (default)
stable -> 9.10 (-> v9.10.1) (default)
iojs -> N/A (default)
lts/* -> lts/carbon (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.14.1 (-> N/A)
lts/carbon -> v8.11.1 (-> N/A)

  • How did you install nvm? (e.g. install script in readme, Homebrew): wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash

nvm says 'no .nvmrc file found' when the problem is that the version inside of said .nvmrc is not installed.

I have a systemd service that calls nvm like this.

/home/kenny/.nvm/nvm-exec nodemon ./src/index.js

the output was: Mar 31 21:06:00 vm5 start.sh[3021]: No NODE_VERSION provided; no .nvmrc file found

the contents of the .nvmrc file are: v9.7.0

The error disappeared after running nvm install 9.7.0 --reinstall-packages-from=node

I got the thing to work but I want to inform you that the error message is wrong it should say that the version inside the .nvmrc is not installed, not that there is no .nvmrc file.

HristoKolev avatar Mar 31 '18 18:03 HristoKolev

Thanks, this message should definitely be improved.

ljharb avatar Apr 02 '18 15:04 ljharb

I've run into this a couple of times as well. It would have helped me if nvm-exec just didn't suppress the error message from the failing nvm use command.

Also, this particular instance of the problem could be sidestepped by nvm-exec running nvm install instead of nvm use. Maybe it could support an --install switch similar to nvm use --install?

papandreou avatar Nov 16 '18 13:11 papandreou

nvm use --install isn’t a thing, because you can always nvm install to get that behavior. Since nvm-exec doesn’t have that choice, an install option for it might make sense.

nvm-exec isn’t the primary use cases for nvm, so it makes sense to me that this hasn’t come up yet, but I’d accept a pr that improved the error message for nvm-exec as well.

ljharb avatar Nov 16 '18 16:11 ljharb

nvm use --install isn’t a thing, because you can always nvm install to get that behavior.

Ah, sorry, I meant nvm.sh --install.

nvm-exec isn’t the primary use cases for nvm, so it makes sense to me that this hasn’t come up yet, but I’d accept a pr that improved the error message for nvm-exec as well.

Sounds good!

For the record, my use case for nvm-exec is a launch config for the vscode debugger so that the node version specified by the project's .nvmrc gets picked up: https://github.com/Microsoft/vscode/issues/16173#issuecomment-343223708

papandreou avatar Nov 16 '18 23:11 papandreou

nvm install node , nvm use node fixed the issue for me.

t-markey avatar Jun 16 '22 04:06 t-markey

This has not been fixed yet.

  1. create foo/.nvmrc with v10 in it
  2. cd foo
  3. ~/.nvm/nvm-exec npm

expected: nvm-exec to complain that v10 is not installed actual result: No NODE_VERSION provided; no .nvmrc file found

bf avatar Jul 06 '23 09:07 bf

@bf yes, the issue being open indeed means it has not been fixed yet :-)

ljharb avatar Jul 06 '23 21:07 ljharb