Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
HristoKolev opened this issue Mar 31, 2018 · 9 comments · May be fixed by #3308
Labels
bugs Oh no, something's broken :-( pull request wanted This is a great way to contribute! Help us out :-D

Comments

@HristoKolev
Copy link

  • 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.

@ljharb ljharb added bugs Oh no, something's broken :-( pull request wanted This is a great way to contribute! Help us out :-D labels Apr 2, 2018
@ljharb
Copy link
Member

ljharb commented Apr 2, 2018

Thanks, this message should definitely be improved.

@papandreou
Copy link

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?

@ljharb
Copy link
Member

ljharb commented Nov 16, 2018

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.

@papandreou
Copy link

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: microsoft/vscode#16173 (comment)

@t-markey

This comment was marked as off-topic.

@bf
Copy link

bf commented Jul 6, 2023

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

@ljharb
Copy link
Member

ljharb commented Jul 6, 2023

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

@userwiths
Copy link

userwiths commented Mar 6, 2024

Hey, I tried to see if I could fix this one real quick.
After reading for some time through the code managed to get it to behave better on my local (Linux Arch) machine and display a more expressive message in case the versions differ.

Knowing this is a big project and heavily relied on would be glad to hear if this could be improved enough to resolve this issue or if it is even in the right direction.

Sample result with v10 installed
image

@ljharb
Copy link
Member

ljharb commented May 16, 2024

@khs1337 nvm-exec isn't meant to be ran directly. nvm is a sourced shell script, and then you'd run nvm install to auto-install and use the .nvmrc version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugs Oh no, something's broken :-( pull request wanted This is a great way to contribute! Help us out :-D
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants