-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node.js support #2996
Comments
Please see this issue too. |
Experimentally, I've added Node.js to aqua-registry again.
Please read the setup instruction in the release note too. I'd really appreciate if you try this out and give us your feedback. |
Oh, I found that the change of Node.js version isn't reflected... |
Thanks @suzuki-shunsuke. I use aqua on Windows. |
Oops. I see. I'm sorry about that. |
Windows has a different API of environment variables from Linux and macOS, so maybe it's difficult. |
Here is how Scoop installs Node on Windows: {
"version": "22.6.0",
"description": "An asynchronous event driven JavaScript runtime designed to build scalable network applications.",
"homepage": "https://nodejs.org",
"license": "MIT",
"architecture": {
"64bit": {
"url": "https://nodejs.org/dist/v22.6.0/node-v22.6.0-win-x64.7z",
"hash": "3d280cd238e4010b862f5668ea84741d17e014c834ba2e12616a0c3effdda2eb",
"extract_dir": "node-v22.6.0-win-x64"
},
"32bit": {
"url": "https://nodejs.org/dist/v22.6.0/node-v22.6.0-win-x86.7z",
"hash": "d6da737a1029c7ca9bc507727b841bf37dde104e5bce6e9e9d3fdf1c256abf3e",
"extract_dir": "node-v22.6.0-win-x86"
},
"arm64": {
"url": "https://nodejs.org/dist/v22.6.0/node-v22.6.0-win-arm64.7z",
"hash": "c17433d0efdd6ca8e14af168b6301a992d2bfeeab83c1fb11efa0c8e7f275d91",
"extract_dir": "node-v22.6.0-win-arm64"
}
},
"persist": [
"bin",
"cache"
],
"env_add_path": [
"bin",
"."
],
"post_install": [
"# Set npm prefix to install modules inside bin and npm cache so they persist",
"Set-Content -Value \"prefix=$persist_dir\\bin`ncache=$persist_dir\\cache\" -Path \"$dir\\node_modules\\npm\\npmrc\""
],
"checkver": {
"url": "https://nodejs.org/dist/index.json",
"jsonpath": "$..version",
"regex": "v([\\d.]+)"
},
"autoupdate": {
"architecture": {
"64bit": {
"url": "https://nodejs.org/dist/v$version/node-v$version-win-x64.7z",
"extract_dir": "node-v$version-win-x64"
},
"32bit": {
"url": "https://nodejs.org/dist/v$version/node-v$version-win-x86.7z",
"extract_dir": "node-v$version-win-x86"
},
"arm64": {
"url": "https://nodejs.org/dist/v$version/node-v$version-win-arm64.7z",
"extract_dir": "node-v$version-win-arm64"
}
},
"hash": {
"url": "$baseurl/SHASUMS256.txt.asc"
}
}
} |
Please try pre-release versions and give your feedback!Dear folks, About the history of Node.js support, please see the following links too.
Unlike other aqua features, Node.js support tightly depends on shell such as Bash and Zsh, so tests on various environments are necessary. If you help us, we can find and fix bugs, improve the quality, and release this feature officially quickly. If you have any feedback, please post comments to this issue or the pull request. Supported environment
Set up
This feature hasn't been released officially yet.
aqua upa v2.31.0-1 registries:
- type: standard
ref: v4.215.0-2 # renovate: depName=aquaproj/aqua-registry
packages:
- name: nodejs/[email protected]
And you need to add scripts to your shell configuration .bashrc eval "$(aqua set-shell bash)" .zshrc eval "$(aqua set-shell zsh)" Note that
Try
aqua i -l
node -v
npm -v
npm i -g zx # Install a command `zx` https://github.com/google/zx
zx -v
aqua up [email protected] # Change the node version
node -v
npm -v
npm i -g zx
zx -v In this example, we install zx, but off course you can also install other tools. How does this feature work?This is the detail of the feature, so you don't have to read this section necessarily.
In case of Zsh, aqua uses the hook function ( eval "$(aqua set-shell <shell type>)"
e.g. shell:
env:
PATH: node-{{.Version}}-{{.OS}}-{{.Arch}}/bin
|
@suzuki-shunsuke I use aqua on Windows, so I won't be able to test this out, but thanks for the detailed feedback.
The detailsYou mentioned the following:
In response to your statement above, I just wanted to add more details about other options available: According to the npm docs:
And:
And:
And:
And:
Given all that context, the following methods could also be used: NPM_CONFIG_PREFIXAqua export NPM_CONFIG_PREFIX=$(aqua root-dir)/npm-global The docs could then be updated to:
Ideally, However, In the case where the shim:
env:
NPM_CONFIG_PREFIX: {{.AQUA_ROOT_DIR}}/npm-global npmrc FileAnother solution is to do nothing at the implementation level, but add documentation to guide users to create a prefix=/path/to/directory Users would still need to update their PATH: > export PATH="$(aqua root-dir)/bin:/path/to/directory/bin:$PATH" NODE_PATHThe environment (whether through export NODE_PATH="$(aqua root-dir)/node-path" This doesn't tell npm where to install packages, but it does tell node where to look for globally installed packages. |
Thank you for your suggestion. When we configure pros: We can share tools between multiple Node.js versions. We don't have to reinstall tools when we change Node.js versions. cons: The share of the install path between multiple Node.js versions may cause some trouble. |
This is very awesome. |
@suzuki-shunsuke This is true:
One way to achieve separation if this is a problem, is to isolate the aqua environments on a per-project level. This is how I am currently doing it: Using a justfile to control my environment for a project, I have the following configuration: # this is the key part (every project has its own AQUA_ROOT_DIR so that they don't interfere with each other)
export AQUA_ROOT_DIR := join(env("LOCALAPPDATA"), "aquaproj-aqua-project-1")
aqua_bin := join(AQUA_ROOT_DIR, "bin")
aqua_node := join(AQUA_ROOT_DIR, "npm-global/bin")
export PATH := aqua_bin + ";" + aqua_node + ";" + env("PATH")
init:
aqua i
npm install -g zx
zx -v Running the So if I have another project that uses a different version of node/npm, I'll just modify the export AQUA_ROOT_DIR := join(env("LOCALAPPDATA"), "aquaproj-aqua-project-2") I install If I wanted to use the init:
#!pwsh.exe
aqua set-shell pwsh | out-string | iex
aqua i
npm install -g zx
zx -v This approach would be a bit more cumbersome, since I'd either have to do The |
Hmm. I think it's a bit hard to change AQUA_ROOT_DIR by Node.js version.
BTW, I'm wondering why you change AQUA_ROOT_DIR by project.
I understand, but I don't want to support this pattern as much as possible because it tightly depends on environments. |
One of problems of I'm not sure how aqua alternatives such as asdf address this issue. |
I might be doing some unnecessary steps then. Thanks for highlighting this, I'll adjust my approach and see if I can remember why I did this in the first place.
I agree. I like the aqua approach very much.
Good to know this limitation. |
Initial testing shows that it works perfect with pulumi and typescript 👍 |
Thank you for your feedback! Awesome!
|
|
Same as https://pip.pypa.io/en/stable/cli/pip_install/#cmdoption-t So aqua can also support Python by same approach without In case of Node.js
You don't have to use aqua's pre-release version. registries:
- type: standard
ref: v4.215.0-2 # renovate: depName=aquaproj/aqua-registry
packages:
- name: nodejs/[email protected] Set the environment variable. export NPM_CONFIG_PREFIX="$(aqua root-dir)/npm-global" # You can change the path freely
export PATH=$NPM_CONFIG_PREFIX/bin:$PATH Then you can install Node.js, and install and execute tools by npm. aqua i
npm i -g zx
which zx
zx -v
aqua up [email protected]
zx -v
node -v
npm -v I've confirmed it works fine on my laptop. |
Thanks for confirming @suzuki-shunsuke. It doesn't look like this works in Windows yet. My |
Oh, you're right. |
Could you try this? aquaproj/aqua-registry@b1b803e registries:
- type: standard
ref: b1b803eb9e1eb9759908616413978dc1d6f92eea |
@suzuki-shunsuke I get the following: ❯ aqua i -l
INFO[0000] creating a hard link to aqua-proxy aqua_version=2.30.0 command=corepack env=windows/amd64 program=aqua
INFO[0000] creating a hard link to aqua-proxy aqua_version=2.30.0 command=node env=windows/amd64
program=aqua
INFO[0000] creating a hard link to aqua-proxy aqua_version=2.30.0 command=npm env=windows/amd64 program=aqua
INFO[0000] creating a hard link to aqua-proxy aqua_version=2.30.0 command=npx env=windows/amd64 program=aqua
❯ node --version
INFO[0000] download and unarchive the package aqua_version=2.30.0 env=windows/amd64 exe_name=node package_name=nodejs/node package_version=v22.6.0 program=aqua registry=standard
Downloading nodejs/node v22.6.0 100% |███████████████████████████████████████| (34/34 MB, 10 MB/s)
INFO[0008] rename a file aqua_version=2.30.0 env=windows/amd64 exe_name=node file_name=corepack new="C:\\Users\\user2\\AppData\\Local\\aquaproj-aqua-sdl-tms\\pkgs\\http\\nodejs.org\\dist\\v22.6.0\\node-v22.6.0-win-x64.zip\\node-v22.6.0-win-x64\\corepack.exe" old="C:\\Users\\user2\\AppData\\Local\\aquaproj-aqua-sdl-tms\\pkgs\\http\\nodejs.org\\dist\\v22.6.0\\node-v22.6.0-win-x64.zip\\node-v22.6.0-win-x64\\corepack" package_name=nodejs/node package_version=v22.6.0 program=aqua registry=standard
INFO[0008] rename a file aqua_version=2.30.0 env=windows/amd64 exe_name=node file_name=npm new="C:\\Users\\user2\\AppData\\Local\\aquaproj-aqua-sdl-tms\\pkgs\\http\\nodejs.org\\dist\\v22.6.0\\node-v22.6.0-win-x64.zip\\node-v22.6.0-win-x64\\npm.exe" old="C:\\Users\\user2\\AppData\\Local\\aquaproj-aqua-sdl-tms\\pkgs\\http\\nodejs.org\\dist\\v22.6.0\\node-v22.6.0-win-x64.zip\\node-v22.6.0-win-x64\\npm" package_name=nodejs/node package_version=v22.6.0 program=aqua registry=standard
INFO[0008] rename a file aqua_version=2.30.0 env=windows/amd64 exe_name=node file_name=npx new="C:\\Users\\user2\\AppData\\Local\\aquaproj-aqua-sdl-tms\\pkgs\\http\\nodejs.org\\dist\\v22.6.0\\node-v22.6.0-win-x64.zip\\node-v22.6.0-win-x64\\npx.exe" old="C:\\Users\\user2\\AppData\\Local\\aquaproj-aqua-sdl-tms\\pkgs\\http\\nodejs.org\\dist\\v22.6.0\\node-v22.6.0-win-x64.zip\\node-v22.6.0-win-x64\\npx" package_name=nodejs/node package_version=v22.6.0 program=aqua registry=standard
v22.6.0
❯ npm --version
FATA[0000] aqua failed aqua_version=2.30.0 env=windows/amd64 error="it failed to start the process" exe_name=npm package_name=nodejs/node package_version=v22.6.0 program=aqua
❯ npx --version
FATA[0000] aqua failed aqua_version=2.30.0 env=windows/amd64 error="it failed to start the process" exe_name=npx package_name=nodejs/node package_version=v22.6.0 program=aqua
❯ node --version
v22.6.0
❯ gcm node | select source -expandproperty source
C:\Users\user2\AppData\Local\aquaproj-aqua-sdl-tms\bin\node.exe
❯ gcm npm | select source -expandproperty source
C:\Users\user2\AppData\Local\aquaproj-aqua-sdl-tms\bin\npm.exe
❯ gcm npx | select source -expandproperty source
C:\Users\user2\AppData\Local\aquaproj-aqua-sdl-tms\bin\npx.exe |
Thank you for your confirmation. Hmm. This setting may be wrong. files:
- name: corepack
src: node-{{.Version}}-{{.OS}}-{{.Arch}}/corepack
- name: node
src: node-{{.Version}}-{{.OS}}-{{.Arch}}/node
- name: npm
src: node-{{.Version}}-{{.OS}}-{{.Arch}}/npm
- name: npx
src: node-{{.Version}}-{{.OS}}-{{.Arch}}/npx We need to download the tarball and check the correct paths of them. |
Could you try this? aquaproj/aqua-registry@e833e85 registries:
- type: standard
ref: e833e85f301e8ed08c06c253463028bef80b8b8d I've confirmed that it works fine on GitHub Actions Windows Runner using action-tmate. runneradmin@fv-az534-393 MINGW64 /d/a/aqua-registry/aqua-registry
# node -v
v22.6.0
runneradmin@fv-az534-393 MINGW64 /d/a/aqua-registry/aqua-registry
# npm -v
10.8.2
runneradmin@fv-az534-393 MINGW64 /d/a/aqua-registry/aqua-registry
# npx -v
10.8.2
runneradmin@fv-az534-393 MINGW64 /d/a/aqua-registry/aqua-registry
# corepack -v
0.29.3 🤔 # echo $NPM_CONFIG_PREFIX
C:\Users\runneradmin\AppData\Local\aquaproj-aqua\npm-global
# aqua exec -- npm i -g zx
changed 5 packages in 2s
# which zx
/c/npm/prefix/zx
# ls $NPM_CONFIG_PREFIX
ls: cannot access 'C:\Users\runneradmin\AppData\Local\aquaproj-aqua\npm-global': No such file or directory
# ls "C:\Users\runneradmin\AppData\Local\aquaproj-aqua"
bin internal pkgs policies |
The binaries work: ❯ node --version
INFO[0000] download and unarchive the package aqua_version=2.30.0 env=windows/amd64 exe_name=node package_name=nodejs/node package_version=v22.6.0 program=aqua registry=standard
Downloading nodejs/node v22.6.0 100% |████████████████████████████████████████████| (34/34 MB, 7.4 MB/s)
v22.6.0
❯ npx --version
10.8.2
❯ npm -v
10.8.2
❯ corepack -v
0.29.3
❯ gcm npx | select source -expandproperty source
C:\Users\user2\AppData\Local\aquaproj-aqua-sdl\bin\npx.exe
❯ gcm node | select source -expandproperty source
C:\Users\user2\AppData\Local\aquaproj-aqua-sdl\bin\node.exe
❯ gcm corepack | select source -expandproperty source
C:\Users\user2\AppData\Local\aquaproj-aqua-sdl\bin\corepack.exe
❯ gcm npm | select source -expandproperty source
C:\Users\user2\AppData\Local\aquaproj-aqua-sdl\bin\npm.exe I'll test the NPM_CONFIG_PREFIX next. The error you are getting here is a common occurrence when running native windows programs in a mingw64 environment:
You can try setting NPM_CONFIG_PREFIX using unix paths in your runner: # echo $NPM_CONFIG_PREFIX
/c/Users/runneradmin/AppData/Local/aquaproj-aqua/npm-global |
@suzuki-shunsuke Setting NPM_CONFIG_PREFIX and updating my path works as expected! My export NPM_CONFIG_PREFIX := join(source_directory(), ".npm")
export PATH := NPM_CONFIG_PREFIX + path_sep + aqua_bin + path_sep + proto_shims + path_sep + proto_bin + path_sep + GOBIN + path_sep + tms_bin + path_sep + tms_node_bin + path_sep + env("PATH")
check-bla:
echo "$Env:NPM_CONFIG_PREFIX"
aqua exec -- npm i -g zx
gcm zx | select source -ExpandProperty source
zx --version
Running the ❯ just check-bla
echo "$Env:NPM_CONFIG_PREFIX"
C:\Users\user2\sdl\src\tms\.npm
aqua exec -- npm i -g zx
changed 5 packages in 1s
gcm zx | select source -ExpandProperty source
C:\Users\user2\sdl\src\tms\.npm\zx.ps1
zx --version
8.1.4 |
Great! Thank you! |
@suzuki-shunsuke It also works with an older version of node: - name: nodejs/[email protected] ❯ just check-bla
echo "$Env:NPM_CONFIG_PREFIX"
C:\Users\user2\sdl\src\tms\.npm
uutils.exe rm -rf "$Env:NPM_CONFIG_PREFIX"
aqua i -l
npm i -g zx
INFO[0000] download and unarchive the package aqua_version=2.30.0 env=windows/amd64 exe_name=npm package_name=nodejs/node package_version=v20.12.2 program=aqua registry=standard
Downloading nodejs/node v20.12.2 100% |████████████████████████████████████████████| (30/30 MB, 7.6 MB/s)
added 5 packages in 3s
gcm zx | select source -ExpandProperty source
C:\Users\user2\sdl\src\tms\.npm\zx.ps1
zx --version
8.1.4
node --version
v20.12.2
npm --version
10.5.0
npx --version
10.5.0 |
@suzuki-shunsuke Thanks for all your efforts. Let me know if there is anything else you'd like me to check. |
It works perfectly for me too. I try it with my simple nodejs repository on Codespaces. First I installed
|
@suzuki-shunsuke The node tarball also contains npm.ps1 and npx.ps1. Can you also add those files to aquaproj/aqua-registry@e833e85 Running from inside powershell, calling into ps1 scripts is more convenient than calling into cmd files. My current workaround is to install node via aqua, but then replace the npm using npm itself: ❯ aqua i -l
❯ npm install -g npm
❯ ls $Env:NPM_CONFIG_PREFIX
Directory: C:\Users\user2\sdl\src\tms\.npm
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 2024/08/23 09:58 node_modules
-a--- 2024/08/23 09:58 405 npm
-a--- 2024/08/23 09:58 333 npm.cmd
-a--- 2024/08/23 09:58 837 npm.ps1
-a--- 2024/08/23 09:58 405 npx
-a--- 2024/08/23 09:58 333 npx.cmd
-a--- 2024/08/23 09:58 837 npx.ps1
❯ gcm npm | select source -expandproperty source
C:\Users\user2\sdl\src\tms\.npm\npm.ps1
❯ gcm npx | select source -expandproperty source
C:\Users\user2\sdl\src\tms\.npm\npx.ps1 |
Do you mean to replace *.cmd with *.ps1? - name: npm
src: node-{{.Version}}-{{.OS}}-{{.Arch}}/npm.ps1
- name: npx
src: node-{{.Version}}-{{.OS}}-{{.Arch}}/npx.ps1 aqua associates commands such as |
@suzuki-shunsuke Ok that makes sense. I was just wondering why a I reverted back to using the aqua npm.exe and npx.exe, they work fine. |
Thank you guys. @W1M0R @bluegumcity @Kesin11 Through the above discussion, we decided to use npm's eval "$(aqua set-shell <bash|zsh>)" # Remove this Instead, please configure npm's export NPM_CONFIG_PREFIX="${XDG_DATA_HOME:-$HOME/.local/share}/npm-global" # You can change the path freely
export PATH=$NPM_CONFIG_PREFIX/bin:$PATH About npm's Remaining tasks
|
All task has been done. Node.js support is out 🎉 |
Thanks @suzuki-shunsuke. Just a windows specific note (the documentation site may need to state this): ❯ exa $Env:NPM_CONFIG_PREFIX
node_modules npm npm.cmd npm.ps1 npx npx.cmd npx.ps1 zx zx.cmd zx.ps1 Notice there is no So the $Env:PATH = "$NPM_CONFIG_PREFIX;$PATH" Also, I find it useful for aqua bins to take preference (because aqua is more declarative and responds to version changes automatically), so I do this: $Env:PATH = "$AQUA_ROOT_DIR/bin;$NPM_CONFIG_PREFIX;$PATH" |
Thank you. I'll update the document. |
Feature Overview
Please add node and npm to the package registry.
Why is the feature needed?
Very convenient. If aqua supports node, then I don't need proto, pixi or vfox for node.
Workaround
Use proto to install node.
Example Code
No response
Note
I see the documentation clearly states that node is not supported: https://aquaproj.github.io/docs/#use-aqua-along-with-asdf
This is still a request to see what could be done about that limitation.
Reference
Reference
nodejs/node
aqua-registry#855nodejs/node
aqua-registry#1436The text was updated successfully, but these errors were encountered: