Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Shunsuke Suzuki
Shunsuke Suzuki

Posted on

     

aqua Now Supports Node.js

aqua is a CLI version manager written in Go.

https://aquaproj.github.io/

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
Enter fullscreen modeExit fullscreen mode

Then you can run commands such asnode andnpm.

node-vnpm-v
Enter fullscreen modeExit fullscreen mode

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
Enter fullscreen modeExit fullscreen mode

Once configured, you can install tools bynpm i -g.

npm i-g zxzx-v
Enter fullscreen modeExit fullscreen mode

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
Enter fullscreen modeExit fullscreen mode

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)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Platform Engineer / OSS Developer / Go / Terraform / CIAuthor of aqua / tfcmt / tfactionhttps://x.com/szkdash_en
  • Location
    Japan
  • Work
    Platform Engineer
  • Joined

More fromShunsuke Suzuki

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp