Tag Archives: vuecli

NPM Install vue-cli Error: internal/modules/cjs/loader.js (Error: Cannot find module ‘D:\Program\nodejs\node_global\node_modules\vue-cli\bin\vue’)

1. Vue cli installation encountered a problem

Install the new version of Vue cli command: NPM install – G @Vue/cli. After successful installation, use Vue – V to check the version number. An error is found:

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 checking the Vue version or creating a new Vue project. Uninstalling Vue CLI and reinstalling will also report an error.

2. Solution

1. Find the installation location of your Vue first (you need to view the global location of your NPM installation)

My is installed in this directory. You can see that there will be two files. When there is a problem, the vue.cmd file is the latest (today’s), but the Vue file is 2020 (before). Therefore, it is speculated that the Vue versions of the two files may be inconsistent.

2. Get the location of the Vue file and delete it

Delete the remaining Vue files (delete these 2 files)

3. Uninstall Vue CLI and then reinstall it.

PS D:\Program\nodejs\node_global> vue -V
@vue/cli 4.5.13

This is successful.

Summary:

1. You can install without an administrator, but CMD should be run as an administrator when uninstalling;

2. Be calm when you encounter problems and remember to find the cause of the problem according to the error information. (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, but your problems may not be solved. It may lead to some other pits, so be careful.)