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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add installation options to use, run & exec commands to install node version if not installed #2287

Open
matthewadams opened this issue Aug 20, 2020 · 4 comments

Comments

@matthewadams
Copy link

Operating system and version:

macOS 10.15.4 (19E287)

nvm debug output:

馃嵑 nvm debug
nvm --version: v0.34.0
$TERM_PROGRAM: iTerm.app
$SHELL: /usr/local/bin/bash
$SHLVL: 1
$HOME: /Users/matthewadams
$NVM_DIR: '$HOME/.nvm'
$PATH: $HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$HOME/bin:$NVM_DIR/versions/node/v10.1.0/bin:$HOME/.sdkman/candidates/scala/current/bin:$HOME/.sdkman/candidates/java/current/bin:$HOME/.sdkman/candidates/groovy/current/bin:$HOME/.sdkman/candidates/gradle/current/bin:$HOME/google-cloud-sdk/bin:$HOME/.git-subrepo/lib:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/MacGPG2/bin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 5.0.16(1)-release (x86_64-apple-darwin19.3.0)'
uname -a: 'Darwin 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64'
OS version: Mac 10.15.4 19E287
curl: /usr/bin/curl, curl 7.64.1 (x86_64-apple-darwin19.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.39.2
wget: /usr/local/bin/wget, GNU Wget 1.20.3 built on darwin18.6.0.
git: /usr/local/bin/git, git version 2.24.0
grep: /usr/bin/grep (grep --color=auto), grep (BSD grep) 2.5.1-FreeBSD
awk: /usr/bin/awk, awk version 20070501
sed: illegal option -- -
usage: sed script [-Ealn] [-i extension] [file ...]
       sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
sed: /usr/bin/sed,
cut: illegal option -- -
usage: cut -b list [-n] [file ...]
       cut -c list [file ...]
       cut -f list [-s] [-d delim] [file ...]
cut: /usr/bin/cut,
basename: illegal option -- -
usage: basename string [suffix]
       basename [-a] [-s suffix] string [...]
basename: /usr/bin/basename,
rm: illegal option -- -
usage: rm [-f | -i] [-dPRrvW] file ...
       unlink file
rm: /bin/rm,
mkdir: illegal option -- -
usage: mkdir [-pv] [-m mode] directory ...
mkdir: /bin/mkdir,
xargs: illegal option -- -
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
             [-L number] [-n number [-x]] [-P maxprocs] [-s size]
             [utility [argument ...]]
xargs: /usr/bin/xargs,
nvm current: v10.1.0
which node: $NVM_DIR/versions/node/v10.1.0/bin/node
which iojs:
which npm: $NVM_DIR/versions/node/v10.1.0/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v10.1.0
npm root -g: $NVM_DIR/versions/node/v10.1.0/lib/node_modules

nvm ls output:

馃嵑 nvm ls
       v0.12.18
         v4.9.1
        v5.12.0
         v6.0.0
        v6.17.1
         v8.0.0
         v8.3.0
         v8.4.0
         v8.6.0
        v8.10.0
        v8.15.1
        v8.16.2
        v8.17.0
        v9.11.2
        v10.0.0
->      v10.1.0
       v10.12.0
       v10.13.0
       v10.14.2
       v10.15.3
       v10.16.3
       v10.17.0
       v10.20.1
       v11.13.0
       v11.15.0
       v12.10.0
       v12.13.0
       v12.14.0
       v12.16.0
       v12.16.3
       v12.17.0
        v13.5.0
       v13.14.0
        v14.1.0
        v14.2.0
        v14.8.0
         system
default -> 14 (-> v14.8.0)
node -> stable (-> v14.8.0) (default)
stable -> 14.8 (-> v14.8.0) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/erbium (-> N/A)
lts/argon -> v4.9.1
lts/boron -> v6.17.1
lts/carbon -> v8.17.0
lts/dubnium -> v10.22.0 (-> N/A)
lts/erbium -> v12.18.3 (-> N/A)

How did you install nvm?

install script in readme

What steps did you perform?

nvm use --install 10.4.0 without having installed 10.4.0 prior to invocation

What happened?

N/A: version "10.4.0 -> N/A" is not yet installed.

You need to run "nvm install 10.4.0" to install it before using it.

What did you expect to happen?

nvm should have automatically installed 10.4.0 if it wasn't already installed.

It would be great if use, run & exec provided options for automatically installing the targeted node version if it's not already installed. I'd expect the option to be --install/-i. It would also be nice if a --silent/-s option were supported for silent installation. That way, a user could issue the command nvm run -is 10.4.0 blah.js and nvm would silently install 10.4.0 if it wasn't there then run the command. Running nvm run -is blah.js would silently install & use the node version according to .nvmrc.

@ljharb
Copy link
Member

ljharb commented Aug 20, 2020

nvm use --install isn't a thing; nvm install already does "install if needed + use".

Supporting --silent on nvm install seems somewhat reasonable, but i'm not excited about silently installing a node version that doesn't get cleaned up later.

@matthewadams
Copy link
Author

@ljharb I don't see the big deal WRT clean up. I have many nvm-managed node versions.

However, if you wanted to, you could make the default behavior to be to remove the installed version after execution, and let users pass a flag to opt out of automatic cleanup with a --no-remove option or something.

The point of my request is really just to reduce the number of commands that have to be run. I just want to nvm run blah.js and it should Just Work鈩笍 without me having to install the targeted Node version or not in a separate step.

@ljharb
Copy link
Member

ljharb commented Aug 20, 2020

I'm not sure why nvm install && nvm run blah is all that much harder?

(or if you don't want the nvm use, you could do (nvm install && nvm run blah), i suppose)

@matthewadams
Copy link
Author

It's just more to type, that's all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants