Installing Babel CLI on macOS Mojave

Aug 05, 2019    

I’m taking a modern JavaScript course on Udemy. I highly recommend it if you’ve never used ES6 before.

The instructor introduces Babel in one of the sections, and has us install the Babel command line tool.

Using npm, you should be able to install it like so:

npm install -g babel-cli@6.26.0

When I tried this, I got an “EACCES: permission denied” error.

You can try following the instructions here to fix it for you. A lot of people in the course had success with this.

I don’t know what I did to my MacBook, but the suggestions above STILL did not fix it for me.

After scouring Stack Overflow and Google, the only way I could get the Babel CLI to work was to recursively update the permissions of the .npm folder in my home directory:

sudo chown -R $(whoami) ~/.npm

I hope this helps somebody!