- docs
- Start here
- Install a package
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.
ocx package exec nodejs/node:22 -- node --versionv22.23.5The 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:
ocx package install nodejs/node:22Package Version Pathnodejs/node:22 ocx.sh/nodejs/node:22 ~/.ocx/symlinks/ocx.sh/nodejs/node/candidates/22The 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.
Link it where you want it
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.
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:
ocx package install --select nodejs/node:24Package Version Pathnodejs/node:24 ocx.sh/nodejs/node:24 ~/.ocx/symlinks/ocx.sh/nodejs/node/currentRun the binary through current. The path has no version in it:
~/.ocx/symlinks/ocx.sh/nodejs/node/current/content/bin/node --versionv24.22.3Point current back at 22, then run the same path again:
ocx package select nodejs/node:22~/.ocx/symlinks/ocx.sh/nodejs/node/current/content/bin/node --versionv22.23.5The 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:
ocx package env nodejs/node:22The 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:
ocx package uninstall --deselect --purge nodejs/node:22Package Statusnodejs/node:22 removednodejs/node:22 purgedA 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:
ocx package uninstall nodejs/node:24ocx cleanThe 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
- Declare the tools of one repository in Pin a toolchain.
- Put a tool on your
PATHin every shell with the global toolchain, or let shell integration do it per project. - Learn how version tags work, so you know why
22and24pick the builds they do. - List the tags of a repository with
--remoteindex commands, and look up exit code 79 in the exit codes. - Look up flags in the
ocx packagereference and the environment reference.