If you get this error when you try to install something, you need to update your Node.js version. You can update it to the latest version using this command:
brew update && brew upgrade node
Or you can follow these steps:
Check the current version: node -v
Clean the npm cache: npm cache clean -f
Install n: npm install -g n
Install the latest stable version of nodeJS: sudo n stable