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, you need to restart the CMD console.
nodejs module global directory environment variable
npm directory can be searched using npm command: npm config get prefix
Okay, the problem has been solved. Isn’t it super simple and practical? I hope this article can be helpful to everyone.