Error installing angular/cli on macOS mojave - node-pre-gyp

Well I did this and it worked for me.

  1. rm -rf /usr/local/lib/node_modules
  2. brew uninstall node
  3. brew install node --without-npm
  4. echo prefix=~/.npm-packages >> ~/.npmrc
  5. curl -L https://www.npmjs.com/install.sh | sh
  6. add the following line to your ~/.bash_profile (export PATH="$HOME/.npm-packages/bin:$PATH")

  7. Unistall your current @angular/cli (sudo npm uninstall -g @angular/cli)

  8. npm cache clean --force / npm cache verify
  9. xcode-select --install
  10. npm install -g node-gyp
  11. npm install -g @angular/cli (without sudo).

Let me know if it works


You're not doing anything wrong, there is some error related to (probably) fsevents, both official package from node.js (lts and current) and homebrew installs have this issue.

Follow answers on this thread: How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)

[basically you need to remove node, npm, ng files and folders manually]

and install nvm and then node with nvm.