Skip to content

nvm-exec should use the default alias by default #3810

@regseb

Description

@regseb

Operating system and version:

nvm debug output:

Details
nvm --version: v0.40.3
$SHELL: /bin/bash
$SHLVL: 1
whoami: 'osmc'
${HOME}: /home/osmc
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${NVM_DIR}/versions/node/v22.22.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/sbin:/usr/sbin:/usr/osmc/bin:/opt/vc/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 5.1.4(1)-release (arm-unknown-linux-gnueabihf)'
uname -a: 'Linux 5.15.92-1-osmc #1 SMP PREEMPT Tue Jul 25 00:03:42 UTC 2023 aarch64 GNU/Linux'
checksum binary: 'sha256sum'
OS version: OSMC: Open Source Media Center  
random-funcs:       srandom/random
regex-funcs:        internal
compiled limits:
sprintf buffer      8192
maximum-integer     2147483647
awk: awk est /usr/bin/awk, mawk 1.3.4 20200120
curl: curl est /usr/bin/curl, curl 7.74.0 (arm-unknown-linux-gnueabihf) libcurl/7.74.0 OpenSSL/1.1.1w zlib/1.2.11 brotli/1.0.9 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.3.0) libssh2/1.9.0 nghttp2/1.43.0 librtmp/2.3
wget: wget est /usr/bin/wget, GNU Wget 1.21 compilé sur linux-gnueabihf.
ls: impossible d'accéder à 'git': Aucun fichier ou dossier de ce type
git: git est /usr/bin/git, git version 2.30.2
ls: impossible d'accéder à 'grep': Aucun fichier ou dossier de ce type
grep: grep est /usr/bin/grep, grep (GNU grep) 3.6
ls: impossible d'accéder à 'sed': Aucun fichier ou dossier de ce type
sed: sed est /usr/bin/sed, sed (GNU sed) 4.7
ls: impossible d'accéder à 'cut': Aucun fichier ou dossier de ce type
cut: cut est /usr/bin/cut, cut (GNU coreutils) 8.32
ls: impossible d'accéder à 'basename': Aucun fichier ou dossier de ce type
basename: basename est /usr/bin/basename, basename (GNU coreutils) 8.32
ls: impossible d'accéder à 'rm': Aucun fichier ou dossier de ce type
rm: rm est /usr/bin/rm, rm (GNU coreutils) 8.32
ls: impossible d'accéder à 'mkdir': Aucun fichier ou dossier de ce type
mkdir: mkdir est /usr/bin/mkdir, mkdir (GNU coreutils) 8.32
ls: impossible d'accéder à 'xargs': Aucun fichier ou dossier de ce type
xargs: xargs est /usr/bin/xargs, xargs (GNU findutils) 4.8.0
nvm current: v22.22.2
which node: ${NVM_DIR}/versions/node/v22.22.2/bin/node
which iojs: 
which npm: ${NVM_DIR}/versions/node/v22.22.2/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v22.22.2
npm root -g: ${NVM_DIR}/versions/node/v22.22.2/lib/node_modules

nvm ls output:

Details
       v22.21.1
       v22.22.0
       v22.22.1
->     v22.22.2
default -> 22 (-> v22.22.2)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v22.22.2) (default)
stable -> 22.22 (-> v22.22.2) (default)
lts/* -> lts/krypton (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.2 (-> N/A)
lts/hydrogen -> v18.20.8 (-> N/A)
lts/iron -> v20.20.2 (-> N/A)
lts/jod -> v22.22.2
lts/krypton -> v24.14.1 (-> N/A)

How did you install nvm?

Télécharger Node.js®:

# Télécharger et installer nvm :
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash

# au lieu de redémarrer le shell
\. "$HOME/.nvm/nvm.sh"

# Télécharger et installer Node.js :
nvm install 22

# Vérifiez la version de Node.js :
node -v # Doit afficher "v22.22.2".

# Vérifier la version de npm :
npm -v # Doit afficher "10.9.7".

What steps did you perform?

I want to start my Node project using Systemd:

[Unit]
Description=Foo
After=network.target

[Service]
User=osmc
WorkingDirectory=/home/osmc/dev/foo
ExecStart=/home/osmc/.nvm/nvm-exec node src/index.js
Restart=always

[Install]
WantedBy=multi-user.target

What happened?

nvm-exec doesn't know which version of node is being used. So I added the .nvmrc file in my project:

default

What did you expect to happen?

If NODE_VERSION and .npmrc do not exist, nvm-exec uses the default alias by default.

I want my project to use the default version of node that's installed. In an interactive shell, the default alias is used. But with Systemd, .bashrc isn't loaded, so I have to add .npmrc, which seems unnecessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions