Ionic commands not working in directories outside the local user main folder

I am using ionic v-4. Previously, ionic was working perfectly fine in all folders. But suddenly it stopped working.

Now, if the directory is in local user folder, it works right. See below in image (Blue)

But, if I change the directory to some folder inside the local user folder, then it gives me error: (See below in image (Red)

" ‘ionic’ is not recognized as an internal or external command,
operable program or batch file."


I tried to follow up on some previous questions from different forums and uninstalled node, ionic and cordova. Then I cleared cache and then clean installed everything again using

npm install -g ionic

but still it gives me the same error.

I also tried to change the environment variables to the correct path of npm but no change.
Moreover, I tried using command prompt as an administrator too but still same error.

If anyone can suggest me some solution to fix this, I’d be very grateful because I have an ionic exam coming and I need to practice haha :smiley:

PS. My account is the admin account so run as administrator doesn’t really matter.

Try Opening CMD ( Command Prompt ) with administrator:

and then run ionic commands. Hope it will help. `

i tried it already, still gives the same error…

Did you try reinstalling node?

Yes, I uninstalled everything, cleared cache (as suggested by other forums) and then clean installed everything with the -g tag in case. But still got the same error.

Try checking node and ionic version through cmd with these command and share what you get:

node -v 
ionic --v

if you get these both then i can just say, try reset your window.

1 Like

Thank you for your answer. After everything else, resetting my pc solved the problem. :smiley: