Skip to content

Commit

Permalink
feat: nvm (skip base node installation)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpovel committed Apr 4, 2024
1 parent 8a9bf45 commit dfff0bc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
23 changes: 14 additions & 9 deletions debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -310,27 +310,32 @@ install_language_toolchains() {
print_large "Python toolchain installed successfully."
}

install_npm() {
print_large "Installing npm..."
install_nvm() {
print_large "Installing nvm..."

if ! command -v npm &> /dev/null || [ -n "$CI" ]
if ! command -v nvm &> /dev/null || [ -n "$CI" ]
then
sudo apt install nodejs
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
fi

# Installing via https://github.com/nodesource/distributions ships with `npx`,
# but installing from native Debian repos doesn't.
npm list --global npx || command -v npx || sudo npm install --global npx
# https://github.com/nvm-sh/nvm/tree/v0.39.7?tab=readme-ov-file#install--update-script
NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
export NVM_DIR
# shellcheck source=/dev/null
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

print_large "npm installed successfully."
nvm install node # Latest
nvm install --lts # Latest LTS

print_large "nvm installed successfully."
}

install_base_build_packages

install_rust_toolchain
install_go_toolchain
install_python_toolchain
install_npm
install_nvm
}

main() {
Expand Down
9 changes: 9 additions & 0 deletions home/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ export PYENV_ROOT="$HOME/.pyenv"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

# =====================================================================================
# nvm/npm
# =====================================================================================

# Copy-pasted verbatim from what `nvm` sets automatically:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

# =====================================================================================
# Apply
# =====================================================================================
Expand Down

0 comments on commit dfff0bc

Please sign in to comment.