In order to solve the problem that the npm command cannot run normally,
it is connected to the previous blog
After installing the new version of node, the following error will occur when using the npm command
The general meaning is that you can’t recognize what the npm command does.
solution:
1. First make sure that the software does not have administrator privileges to run, right-click the program and select administrator privileges to run
2. If the error still occurs after running with administrator privileges, check the configuration file of node
Find your node installation directory command: where node
See if there are these two files under nodejs, if not, create them
Black screen command to enter the folder after creation
The file address is as shown in the figure. Press the cmd command (personally prefers)
Then enter the command npm config set prefix "the address of your nodejs folder\node_global"
Mine is npm config set prefix "C:\Program Files\nodejs\node_global"
Another command is npm config set cache "address of your nodejs folder\node_cache"
Mine is npm config set cache "C:\Program Files\nodejs\node_cache"
Note that these two commands are completely different, don't think that it is the same command and just change the address
Then it's easier
Find your environment variables, everyone should be familiar with this
Click on your path variable to enter
edit a bit
By default it should be this C:\Users\username\AppData\Roaming\npm\
As shown below
take this
Replace it with this: the address of your nodejs folder\node_global
As shown below
then click OK
and system variables
Add if not
Variable name: NODE_PATH
Variable value: the address of your nodejs folder
then confirm
After saving
Open the software with administrator privileges, select the project to execute the npm command
Then it will run successfully