15

I'm setting up a new Vue project and when I'm running the command npm run serve into CMD, the following error appears:

Error: Cannot find module 'C:\Users\Bram Wicherink\@vue\cli-service\bin\vue-cli-service.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] serve: 'vue-cli-service serve'
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] serve script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Bram Wicherink\AppData\Roaming\npm-cache\_logs\2019-09-13T14_03_01_676Z-debug.log

What do I have to do?

I have read the logs, I uninstalled and reinstalled NPM, Vue, Node.js and read some background information on Google, but nothing worked.

9
  • 1
    Run npm install before running npm run serve Commented Sep 13, 2019 at 14:21
  • Then I get the same error, after running npm install before that command. Commented Sep 13, 2019 at 14:35
  • 3
    Can you try to run npm i @vue/cli-service? Commented Sep 13, 2019 at 14:39
  • Unfortuantely it keeps saying that the module/service cannot be found, after multple times reinstalling NPM and the VUE Package... Commented Sep 13, 2019 at 14:51
  • 3
    It works again! I had to install npm via cmd ('npm install') two times again and strangely it did work? Thanks! Commented Sep 17, 2019 at 6:51

5 Answers 5

16

In my case (Windows), the node_modules\.bin\vue-cli-service.cmd was failing because one of my parent folders had an ampersand character which breaks %~dp0

Sign up to request clarification or add additional context in comments.

3 Comments

you are a god , been stucked from last 2 hrs , installing uninstalling npm , vue , then deleting node modules folder etc. Thanks mate
and what did you do to fix it? Rename the folder?
@marts This was a long time ago but from memory yes - that's the simplest fix.
2

Solution

Removing & from any of the folder's name or sub-folders inside which your project lies will resolve the issue.

Explanation

The & symbol in any of the folders or ancestor/parent folder's name inside which your project lies will initiate a vue-cli execution issue since & is a special character.

The %~dp0 (that’s a zero) variable when referenced within a Windows batch file will expand to the drive letter and path of that batch file.

The variables %0-%9 refer to the command line parameters of the batch file. %1-%9 refer to command-line arguments after the batch file name. %0 refers to the batch file itself.

If you follow the percent character (%) with a tilde character (~), you can insert a modifier(s) before the parameter number to alter the way the variable is expanded. The d modifier expands to the drive letter and the p modifier expands to the path of the parameter.

Example: Let’s say you have a directory on C: called bat_files, and in that directory is a file called example.bat. In this case, %~dp0 (combining the d and p modifiers) will expand to C:\bat_files\.

Comments

1

I had a clean_bins.cmd script run in my project which searches for all /bin/ folders and removes it. After I run that script I had the same problem with vue.

To solve the issue just clean the /node_modules/ folder and run npm install.

1 Comment

Looks like my clean_bins.cmd batch accidentally removed some /bin/ folder in /node_modules/.
0

This is just from my experience concerning this issue using multiple disks on a windows 10 development environment: I have a work machine using multiple hard-drives: one split for the OS and another for file storage. The vue-cli install by following(droning off) the docs by default installed to my primary disk (C:), however attempting to configure -of which was successful- but running from the secondary disk (D:) resulted in the same error. Running vue-cli commands to create and serve the vue js app (the crux of the issue here) on the primary disk (C:) resolved this issue for me.

Please note: this is not an intact solution but rather observation from my end, even if it may sound trivial.

1 Comment

This worked for me as well. Kind of annoying.
0

I had an ampersand character in my parent folder, I took 2 hours to try almost everything... Just delete the "&" and then worked.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.