3

I am trying to install NVM on my Mac using the following command:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

However, I am getting an error with the message: "syntax error near unexpected `(". More details on the error log are provided down below. What am I doing wrong?

VFZ:repo2022 john$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4934  100  4934    0     0    686      0  0:00:07  0:00:07 --:--:--   686
bash: line 1: syntax error near unexpected token `('
bash: line 1: `<!-- Copyright (C) 2016 Intel Corporation. All rights reserved. -->'
VFZ:repo2022 john$ 

System - MAC

P.M
  • 2,880
  • 3
  • 43
  • 53
John doe
  • 31
  • 1
  • 1
  • 6

3 Answers3

7

There is a solution using 'Rosetta 2' From terminal:

$ sudo softwareupdate --install-rosetta

Install NVM using curl (found on the NVM Readme)

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

Then install whatever Node version (example installs latest)

$ nvm install node

Check Node Version

$ node -v

Source: https://dev.to/httpjunkie/setup-node-version-manager-nvm-on-mac-m1-7kl

GatesKennedy
  • 675
  • 4
  • 11
0

Homebrew (brew) makes it easy to install and manage versions of nvm. If you have homebrew already available, please run brew install nvm. And you will be all set.

P.M
  • 2,880
  • 3
  • 43
  • 53
0

If curl doesn't work you can use wget, for which you should have wget installed which you can install using homebrew.

brew install wget

Then run the following command,

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash .

The installer will automatically update the profiles files but if it doesn't you can update it manually like this.

First identify which shell is it that you are using:

echo $0

if its zsh, update the ~/.zprofile file. if its bash, update the ~/.bash_profile file with the following lines

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

After that you can run source ~/.bashrc in case of bash, or run source ~/.zprofile in case of bash, you can then use NVM.

Prajval Singh
  • 501
  • 3
  • 9