How to install the latest @salesforce/cli with node20 using Homebrew.

If you are running on a Mac with homebrew and have node installed, the chances are when you try to install the latest @salesforce/cli it would show that installation was successful. However, any commands you run like sf version will throw this annoying warning.

pauloorquillo@Paulos-MBP VersionControl % sf version
(node:34452) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
@salesforce/cli/2.24.4 darwin-arm64 node-v21.5.0

Update: This issue seems to have been fixed with node-v21.6.0 and higher. Make sure you update to the latest node version. If you are still having the issue check the solution below.

You can ignore the warning if you want. But to fix this you would need to downgrade your node version installed via homebrew. Open up the terminal and do the following commands and reading through my comments.

#uninstall the salesforce cli for a clean install later
npm uninstall @salesforce/cli --global

#list all apps to make sure you have node installed
brew list

#uninstall that version of node
brew uninstall node

#install older version of node
brew install node@20

#update the link in homebrew to look into this latest version
brew link —overwrite node@20 

#check node version
node -v

#finally install the salesforce cli again
npm install @salesforce/cli --global

#check that no warnings are thrown by running this command
sf version

There you go, hope you like this tip and found it useful.

Leave a Reply

Your email address will not be published. Required fields are marked *