Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions apps/site/snippets/en/download/brew.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Download and install Homebrew
curl -o- https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | bash
# Download and install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Add Homebrew to your PATH:
${props.os === 'MAC' ?
`if [ -x /opt/homebrew/bin/brew ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
grep -qs '/opt/homebrew/bin/brew shellenv' ~/.zprofile ~/.zshrc || { echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"'; } >> ~/.zprofile
fi` :
`if [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
grep -qs '/home/linuxbrew/.linuxbrew/bin/brew shellenv' ~/.bashrc ~/.profile || { echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"'; } >> ~/.bashrc
fi`
}
Comment on lines +4 to +14

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? Homebrew's own instructions do not include this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Homebrew's official install.sh does instruct users to do this on both Apple Silicon macOS and Linux — it does not add /opt/homebrew/bin or /home/linuxbrew/.linuxbrew/bin to PATH automatically. At the end of a fresh install, Homebrew prints:

Warning: /opt/homebrew/bin is not in your PATH.
==> Next steps:
- Run these commands in your terminal to add Homebrew to your PATH:
    echo >> ~/.zprofile
    echo 'eval "$(/opt/homebrew/bin/brew shellenv zsh)"' >> ~/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv zsh)"

Without running eval "$(... brew shellenv)" first, the very next line in this snippet (brew install node@26) fails immediately with zsh: command not found: brew on a clean Apple Silicon Mac or Linux machine. And without persisting it to ~/.zprofile / ~/.bashrc, both brew and node become command not found as soon as the user opens a new terminal.


# Download and install Node.js:
brew install node@${props.release.major}

# Add Node.js to your PATH (required for keg-only LTS formulas):
export PATH="$(brew --prefix node@${props.release.major})/bin:$PATH"
grep -qs "$(brew --prefix node@${props.release.major})/bin" ${props.os === 'MAC' ? '~/.zshrc' : '~/.bashrc'} || { echo; echo 'export PATH="'"$(brew --prefix node@${props.release.major})/bin"':$PATH"'; } >> ${props.os === 'MAC' ? '~/.zshrc' : '~/.bashrc'}
Comment on lines +19 to +21

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels rather complex. Why isn't brew adding this to PATH by itself?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because Homebrew's versioned LTS Node formulas (node@24, node@22, etc.) are keg-only (brew info node@24 explicitly reports: node@24 is keg-only, which means it was not symlinked into /opt/homebrew).

So when a user selects an LTS release like v24 on nodejs.org/en/download, brew install node@24 does not link node or npm into /opt/homebrew/bin (or /home/linuxbrew/.linuxbrew/bin). Without adding $(brew --prefix node@24)/bin to PATH, the node -v and npm -v commands right below it fail with command not found, and node remains unavailable in new terminals too.

8 changes: 6 additions & 2 deletions apps/site/snippets/en/download/fnm.bash
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Download and install fnm:
${props.os === 'WIN' ?
'winget install Schniz.fnm' :
'curl -o- https://fnm.vercel.app/install | bash'
props.os === 'MAC' ?
'curl -o- https://fnm.vercel.app/install | bash -s -- --force-no-brew' :

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding --force-no-brew invokes the same FORCE_INSTALL="true" as --force-install. This generates a warning. I do not think this should be the path we recommend users go down, and this goes against fnm's own guidance for installing.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a clean macOS machine without Homebrew, running curl -o- https://fnm.vercel.app/install | bash aborts immediately:

Checking availability of curl... OK!
Checking availability of unzip... OK!
Checking availability of Homebrew (brew)... Missing!

Notice fnm.bash on nodejs.org is already broken on macOS for a second reason too: its PATH line exports $HOME/.local/share/fnm, whereas fnm's macOS installer actually installs into $HOME/Library/Application Support/fnm.

If nodejs.org prefers not to pass --force-no-brew, then the macOS fnm snippet effectively requires Homebrew as an undocumented prerequisite — in which case either stating Homebrew as a prerequisite (and using brew install fnm) or fixing the install method would be needed, because the current curl | bash snippet does not work on a clean Mac.

'curl -o- https://fnm.vercel.app/install | bash'
}

# In lieu of restarting the shell
${props.os === 'WIN' ?
'fnm env --use-on-cd --shell powershell | Out-String | Invoke-Expression' :
'export PATH="$HOME/.local/share/fnm:$PATH"\neval "$(fnm env)"'
props.os === 'MAC' ?
'export PATH="$HOME/Library/Application Support/fnm:$PATH"\neval "$(fnm env)"' :
'export PATH="$HOME/.local/share/fnm:$PATH"\neval "$(fnm env)"'
}

# Download and install Node.js:
Expand Down
4 changes: 4 additions & 0 deletions apps/site/snippets/en/download/n.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Download and install n and Node.js:
curl -fsSL https://raw.githubusercontent.com/mklement0/n-install/stable/bin/n-install | bash -s ${props.release.major}

# In lieu of restarting the shell:
export N_PREFIX="$HOME/n"
export PATH="$N_PREFIX/bin:$PATH"
Comment on lines +4 to +6

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not keen on this; I think we should instead advise restarting the shell, or re-sourcing?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The runtime instructions already cover what to do. I would not make this change.

For example:

===
CONTINUE (y/N)? y
-- Cloning https://github.com/tj/n to '/home/mike/n/n/.repo'...
-- Running local n installation to '/home/mike/n/bin'...
-- Shell initialization file '/home/mike/.bashrc' updated.
-- Installing helper scripts in '/home/mike/n/bin'...
-- Installing the requested Node.js version(s)...
   1 of 1: 26...
  installing : node-v26.13.1
       mkdir : /home/mike/n/n/versions/node/26.13.1
       fetch : https://nodejs.org/dist/v26.13.1/node-v26.13.1-linux-x64.tar.xz
     copying : node/26.13.1
   installed : v26.13.1 (with npm 11.20.0)
=== n successfully installed.
  The active Node.js version is: v26.13.1

  Run `n -h` for help.
  To update n later, run `n-update`.
  To uninstall, run `n-uninstall`.

  IMPORTANT: OPEN A NEW TERMINAL TAB/WINDOW or run `. /home/mike/.bashrc`
             before using n and Node.js.
===

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is that nodejs.org/en/download renders n.bash, node.bash, and npm.bash together inside a single code block with a single "Copy to clipboard" button — just like nvm.bash, fnm.bash, and vp.bash, which all include an # In lieu of restarting the shell step specifically so the trailing node -v and npm -v verification lines in the same block actually succeed when pasted.

Right now, pasting the n block on Linux (or macOS with Xcode CLT) prints n's "OPEN A NEW TERMINAL" message and then immediately executes node -v and npm -v in the same shell, which fail with command not found. Adding the same # In lieu of restarting the shell exports brings n.bash in line with nvm.bash, fnm.bash, and vp.bash.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The observation that the script does not verify the installed versions of node & npm is correct. I would suggest handling this as a separate issue. The maintainer of n may be able to offer a better alternative.

An example of an unattended installation of n on Linux would be:

curl -L https://bit.ly/n-install | bash -s -- -y
. ~/.bashrc
node -v
npm -v

It's not actually clear from the instructions whether it's intended for the script to be executed by copying the whole thing and executing it in one go, or whether a user is expected to execute each one of the commands manually, one after another.


# Node.js already installs during n-install, but you can also install it manually:
# n install ${props.release.major}
2 changes: 1 addition & 1 deletion apps/site/snippets/en/download/zeroinstall.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Get 0install:
${props.os === 'WIN' ? 'winget install 0install' : 'curl -O https://get.0install.net/0install.sh && chmod +x 0install.sh\n./0install.sh\nexport PATH=$HOME/bin:$PATH'}
${props.os === 'WIN' ? 'winget install 0install' : 'curl -O https://get.0install.net/0install.sh && chmod +x 0install.sh\n./0install.sh install home\nexport PATH=$HOME/bin:$PATH'}

# Add Node.js and npm to PATH:
0install add node https://apps.0install.net/javascript/node.xml --version=${props.release.version}
Expand Down