Installing nvm

See https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating I used wget because curl wasn’t installed (WTH). I already had this in my .bashrc

#--------------------------------------------------------------------------------
# To install, see https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating
# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash
# or
# wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash


function addNodeAndNpm() { 
    if [ -r /etc/pki/tls/cert.pem ]
    then
        export NODE_EXTRA_CA_CERTS=/etc/pki/tls/cert.pem
    fi
    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
    [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
    # npm config set strict-ssl false
    # npm config set cafile=/etc/pki/tls/cert.pem
    # export NODE_EXTRA_CA_CERTS=/etc/pki/tls/cert.pem
    # npm publish --registry https://nexus.example.com/repository/npm-local
    # cat ~/.npmrc
    # strict-ssl=false

    # npm login
    # npm publish 

}

Installing nvm on Windows

2024-07-27 Use https://github.com/coreybutler/nvm-windows/releases

2023-01-21 Found several links pointing to use this: https://github.com/coreybutler/nvm-windows so I gave it a try. I installed it in c:\p\nvm and used the symlink (it manages as) c:\p\nvm-nodejs.
The nvm app stores versions of node that it has downloaded in sub-directories such as:

C:\p\nvm

  • v12.13.1
  • v18.13.0
  • v19.4.0 And c:\p\nvm-nodejs points to the version selected. C:\p\nvm-nodejs => C:\p\nvm\v12.13.1

Configuring npm

NPM has two config names depending on what version is selected See https://stackoverflow.com/questions/71914123/warning-in-npm-config-at-latest-version

Old key                  New key
=======                  =======
init.author.name         init-author-name
init.author.email        init-author-email
init.author.url          init-author-url
init.license             init-license

(Q) What version of npm did the names change from init.author.name to init-author-name?
The change from init.author.name to init-author-name in npm configuration properties occurred in npm v7.0.0. Npm v7.0.0 was released October 13, 2020 alongside of Node.js v15.0.0. It included workspaces support, new lockfile format (v2), automatic dependency installation, and changes to the property names (described above).

# Old way (npm < 7)
npm config set init.author.name "John Doe"

# New way (npm >= 7)
npm config set init-author-name "John Doe"

Verifying Installation Works

Install the latest version of node/npm and switch to it nvm install latest 22.5.1 Version 22.5.1 is already installed.

nvm list
22.5.1
20.12.2
20.12.0
* 18.19.0 (Currently using 64-bit executable)
  18.13.0
  18.6.0
  18.5.0
  18.0.0
  17.4.0
  16.15.1
  16.13.2
  12.22.0
  12.16.2

nvm use 22.5
nvm use latest
22.5.1
Now using node v22.5.1 (64-bit)
node --version
v22.5.1

npm --version
10.8.2

On Windows, when changing versions I’m prompted to provide admin credentials because that is how the app works to change/create a symlink (which requires admin rights).


<
Previous Post
Steps used to run NIFI using docker compose
>
Next Post
Notes about using Java’s .stream() feature