Generally, the reason for this problem is that there is a problem with npm installation, and the global module directory is not added to the system environment variable.
Windows users check whether the npm directory is added to the system variable PATH. If it does not exist, it needs to be added manually. After adding it, the CMD console needs to be restarted.
nodejs module global directory environment variables
The npm directory can be found using the npm command: npm config get prefix
Okay, the problem is solved. Isn’t it super simple and practical? I hope this article can be helpful to everyone.