aqua is a CLI version manager written in Go.
As of August 24, 2024, aqua now supports Node.js!
https://aquaproj.github.io/docs/reference/nodejs-support/
How to Manage Node.js Using aqua
You'll needaqua-registry v4.216.0 or later.
To get started, add nodejs/node to your aqua.yaml file.
aqua g-i nodejs/nodeaqua i-l
Then you can run commands such asnode
andnpm
.
node-vnpm-v
Configure npmpreset
config
To install tools globally usingnpm i -g
, you need to configure the npmpreset
config and update thePATH
environment variable.
exportNPM_CONFIG_PREFIX=${XDG_DATA_HOME:-$HOME/.local/share}/npm-global# Feel free to change this pathexportPATH=$NPM_CONFIG_PREFIX/bin:$PATH
Once configured, you can install tools bynpm i -g
.
npm i-g zxzx-v
Even if you change the version of Node.js, you'll still be able to execute tools installed bynpm i -g
.
aqua up node@v20.16.0zx-v
Why do we need to configure npmpreset
config?
For more details, check out the relatedissue.
By default,npm i -g
installs tools in the same directory as Node.js, meaning the installation path depends on the Node.js version.
Currently, aqua can't dynamically update thePATH
environment variable.
We've considered dynamically updating thePATH
environment variable for Node.js, but this feature is highly dependent on the environment (shell), making it difficult to maintain.
- Bash: $PROMPT_COMMAND
- Zsh: hook function
- Fish: ???
- Powershell: ???
- etc
We prefer not to implement such a feature.
Moreover, dynamically updating the environment variable works only on interactive shells, not in shell scripts.
For example, changing the Node.js version within a shell script wouldn’t update the PATH variable correctly.
Therefore, we decided to fix the installation directory using npmpreset
config rather than updating dynamically thePATH
environment variable.
This approach has several benefits.
- It doesn't depend on the environment (shell)
- It doesn't require adding any feature to aqua itself
Top comments(0)
For further actions, you may consider blocking this person and/orreporting abuse