Running ionic serve I get this error : ”[ERROR] ng has unexpectedly closed (exit code 127).”

I am trying to run an ionic app on my Mac . when I run npm install to install the dependencies everything works without any problem .
but when I run ionic serve or ionic s I get this error

[ng] Workspace extension with invalid name (defaultProject) found.
[ng] ****************************************************************************************
[ng] This is a simple server for use in testing or debugging Angular applications locally.
[ng] It hasn't been reviewed for security issues.
[ng]
[ng] DON'T USE IT FOR PRODUCTION!
[ng] ****************************************************************************************
[ng] An unhandled exception occurred: readConfiguration is not a function
[ng] See "/private/tmp/ng-Ba9mkz/angular-errors.log" for further details.

[ERROR] ng has unexpectedly closed (exit code 127).   

as I searched for this error I found some solutions same as running npm install @ionic/app-scripts@latest --save-dev but when I run this command I also get lots of errors which are mostly related to python however i have already installed the python