Install the new version of
npm install -g @vue/cli, after the installation is successful, use
vue -V to check the version number, and find an error:
PS D:\Program\nodejs\node_global> vue -V internal/modules/cjs/loader.js:583 throw err; ^ Error: Cannot find module 'D:\Program\nodejs\node_global\node_modules\vue-cli\bin\vue' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15) at Function.Module._load (internal/modules/cjs/loader.js:507:25) at Function.Module.runMain (internal/modules/cjs/loader.js:742:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3) PS D:\Program\nodejs\node_global> npm -v 6.4.1
This error occurs when viewing the vue version or creating a new vue project. Uninstalling vue-cli and reinstalling it will also cause an error.
1. Find the installation location of your own vue first (you need to check the global location of your npm installation)
Mine is installed in this directory. You can see that there will be two files like this. When the problem occurred, the vue.cmd file was the latest (today), but the vue file was in 2020 (before). So guess it may be caused by the inconsistency of the vue version of these two files.
2. Obtain the location of the vue file and delete it
delete the remaining vue files (delete these 2 files)
3. Reinstall after uninstalling
PS D:\Program\nodejs\node_global> vue -V @vue/cli 4.5.13
This is a success.
1. It is not necessary to install the administrator when installing, but it is best to run CMD as an administrator when uninstalling;
2. Be calm when encountering a problem, and remember to find the cause of the problem based on the error message. (There are too many Baidu search solutions for environmental problems, but many of them are not necessarily the same as the problems you encounter. Some others can solve them, and your problems may not be solved by following them. Maybe it will lead to some other pits. So be careful)