Note: Since macOS High Sierra (10.13) the directory /usr/local/bin
is not modifiable anymore (because of Apple's SIP feature). But using node
and npm
with sudo
is not advisable.
Generally it is best practice to install node using an dedicated version manager like n
or nvm
. This will handle permissions correctly and allows easy upgrading / downgrading the versions.
- Install
node
version managern
curl -L https://git.io/n-install | bash
- Install the latest
node
version withn
n latest
- Optional: If you want to use
yarn
, install it withnpm
(it's awesome! 😉)
npm i -g yarn
- Install
node
version managernvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
- Install the latest
node
version withnvm
nvm install node
- Optional: If you want to use
yarn
, install it withnpm
(it's awesome! 😉)
npm i -g yarn