follow these steps to install a fresh installation of ionic into a macos with nodejs and npm by using simple commands.

1. download and install nodejs: https://nodejs.org/en/download/current

2. After completing installation of NodeJs, open terminal

3. Check NodeJs is installed.
$ node -v

4. install the latest version of npm: This is my current version as of Sept. 2023
$ sudo npm install -g [email protected]

5. Install Ionic command:
$ sudo npm i -g @ionic/cli

6. Check installed Ionic Version:
$ ionic -v

NOTE: when I tried to create a new project, I got an error:

code: ERESOLVE

ERESOLVE: unable to resolve dependency tree

Found: react-dom@undefined

SOLUTION:

sudo chown -R $(whoami) /usr/local/{lib/node_modules,bin,share}

 

Done