nvm: Node.js Version Manager

nvm: Node.js Version Manager

A simple Node.js version manager.

Install nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash

ref:
https://nodejs.org/en/download/current
https://github.com/nvm-sh/nvm

Install Node.js

You could also simply run brew install node if you don't really care about what version you're installing.

# list available Node.js versions
nvm ls-remote

# list installed Node.js versions
nvm ls

# install the latest LTS version
nvm install --lts

nvm install v22.15.0 && \
nvm use v22.15.0 && \
nvm alias default v22.15.0

npm i -g [email protected]
npm i -g [email protected]

nvm uninstall v16.13.2

ref:
https://nodejs.org/en/

Install Node.js Packages

# install the package globally
npm install -g pangu

# install the package in the current folder
# which generate package.json in the same folder
npm install pangu

Override Dependency Version

Use overrides in package.json:

{
  "overrides": {
    "foo": {
      ".": "1.0.0",
      "bar": "1.0.0"
    }
  }
}

ref:
https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides

Pin Package Versions

npm install -g npm-check-updates

npm-check-updates -u --removeRange

ref:
https://github.com/raineorshine/npm-check-updates