Skip to content

Install a package

By the end of this page you have run Node.js without installing it, installed two versions side by side, switched between them and removed them, apart from the one you linked. It assumes OCX is installed. Use this page for machine-wide installs with stable paths for editors and scripts. To get a tool on your PATH in every shell, use the global toolchain instead. Package names such as nodejs/node resolve against the default registry, ocx.sh.

Run a package once

Run Node.js straight from the registry. The first call downloads the package. Later calls with the same version reuse the download.

Run once
Terminal window
ocx package exec nodejs/node:22 -- node --version
v22.23.5

The command ran with the package’s variables layered over your own environment. Add --clean to start from an empty one. Nothing persists on your machine: no install, no symlink. The patch number you see depends on the current 22 release.

Install it

Make the download permanent and give it a stable path. The paths on this page assume the default home directory, ~/.ocx:

Install a version
Terminal window
ocx package install nodejs/node:22
Package Version Path
nodejs/node:22 ocx.sh/nodejs/node:22 ~/.ocx/symlinks/ocx.sh/nodejs/node/candidates/22

The Path column is a candidate symlink. It points at the build installed for 22, so an editor or script can use it as a fixed path.

Besides the candidate and current symlinks that OCX manages, you can ask for a link at a path you choose. It gives a build or an editor a stable path of your own, and the package behind it is kept from ocx clean. The path must not exist yet, and the flag takes one package.

Install and link
Terminal window
ocx package install --link ./.tools/node "nodejs/node:24"

Use stable paths explains when to use it. The ocx package install reference lists the flag.

Switch versions

Install a second version and mark it as the one you use. The --select flag creates a current symlink next to the candidates:

Install and select
Terminal window
ocx package install --select nodejs/node:24
Package Version Path
nodejs/node:24 ocx.sh/nodejs/node:24 ~/.ocx/symlinks/ocx.sh/nodejs/node/current

Run the binary through current. The path has no version in it:

Run through current
Terminal window
~/.ocx/symlinks/ocx.sh/nodejs/node/current/content/bin/node --version
v24.22.3

Point current back at 22, then run the same path again:

Switch back
Terminal window
ocx package select nodejs/node:22
Run after switching
Terminal window
~/.ocx/symlinks/ocx.sh/nodejs/node/current/content/bin/node --version
v22.23.5

The path stayed the same and the version behind it changed. Installing with --select does not put this node on your PATH. The next steps show how to get that.

See the environment

A package can declare environment variables, such as the PATH entry for its bin directory. List what the installed package declares:

List the environment
Terminal window
ocx package env nodejs/node:22

The output is a table with the columns Key, Type and Value. Each value is resolved against the install location. ocx package exec injects exactly these variables into the child process.

Remove the packages

Remove the selected version, clear the current pointer and delete the package data in one command:

Remove one version
Terminal window
ocx package uninstall --deselect --purge nodejs/node:22
Package Status
nodejs/node:22 removed
nodejs/node:22 purged

A plain uninstall removes the candidate symlink and keeps the package data. Uninstall 24 that way, then let ocx clean delete every package nothing references anymore:

Clean up
Terminal window
ocx package uninstall nodejs/node:24
ocx clean

The last command prints one line for each object it deletes. The 22 install is gone. The linked 24 package stays until you delete the link at ./.tools/node, because ocx clean keeps what a link points at.

Next steps