Vue-cli: npm run serve not working

Created on 29 Nov 2019  Â·  9Comments  Â·  Source: vuejs/vue-cli

Version

4.1.1

Environment info

System:
    OS: Windows 7 6.1.7601
    CPU: (4) x64 Intel(R) Core(TM) i5-4200U CPU @ 1.60GHz
  Binaries:
    Node: 10.14.2 - C:\Program Files\nodejs\node.EXE
    Yarn: Not Found
    npm: 6.5.0 - C:\Program Files\nodejs\npm.CMD
  npmGlobalPackages:
    @vue/cli: Not Found

@vue/cli 4.1.1 is actually installed globally and vue command is available.

Steps to reproduce

Create a project using vue create
  • vue create my-project
Go the directory my-project
  • cd my-project
Run my-project with serve
  • npm run serve

What is expected?

The project should start in development mode with hot reload.

What is actually happening?

The command terminates without starting anything.
If we run vue serve instead of npm run serve, it errors out the following in the terminal and exits:

Failed to locate entry file in my/project/directory/path.
Valid entry file should be one of: main.js, index.js, App.vue or app.vue.

So I am assuming npm run serve tries to find either of the above mentioned files but is not able to find any and hence terminates. The reason is, none of the "entry" files are in the project's root directory but inside the src directory.

cannot reproduce

Most helpful comment

I figured out my issue, though I don't know if it also applies to @pratik-abhyankar
Turns out I forgot I had ignore-scripts set to true.
npm config set ignore-scripts false or deleting .npmrc fixed the problem for me and the command now works as expected.

All 9 comments

What's the error log of npm run serve and what's inside the generated project? Would you please upload the repository to GitHub so that we can debug on it?

There is no error on the terminal on running npm run serve. It just terminates. Is there a dedicated log file to check the errors?
I have created a demo repository at https://github.com/pratik-abhyankar/my-app for reproduction. The contents of the project are the default files and folders created by vue-cli. I have not added any of my code or files in it.
This issue can be reproduced on any machine with the default steps of vue-cli, which are in sequence as vue create my-app, cd my-app and npm run serve.

There is no error on the terminal on running npm run serve. It just terminates. Is there a dedicated log file to check the errors?

But there should be at least some output… Maybe it's related to npm? Because this project works totally fine on my machine (both Mac & Windows 10 Virtual Machine).

I currently have the same problem.
Cloning the repo above or creating a new project both have the same result, with the command simply returning without any output.
This is on Windows 10 as well.

How about .\node_modules\.bin\vue-cli-service.cmd serve?

I figured out my issue, though I don't know if it also applies to @pratik-abhyankar
Turns out I forgot I had ignore-scripts set to true.
npm config set ignore-scripts false or deleting .npmrc fixed the problem for me and the command now works as expected.

Nope, there is absolutely no output on the terminal on running npm run serve. It just terminates and returns the control back to user. I installed latest Node.js, npm and vue-cli again and tried the same by creating a new project. I still face the same issue.

However, running the above command worked! I ran the following on my terminal (from VSCode integrated terminal, I use Git bash and not Command Prompt):
./node_modules/.bin/vue-cli-service serve

@Nocory Would you please share your environment information (Node.js, npm, vue-cli etc), and also try running it with this above command?

@Nocory Yes, you were right! I had previously set ignore-scripts to true which is why I was facing this issue. Setting it to false resolves the issue and npm run serve works as intended.

Closing the issue as resolved.

I figured out my issue, though I don't know if it also applies to @pratik-abhyankar
Turns out I forgot I had ignore-scripts set to true.
npm config set ignore-scripts false or deleting .npmrc fixed the problem for me and the command now works as expected.

Thanks, that resolved my issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JIANGYUJING1995 picture JIANGYUJING1995  Â·  3Comments

Gonzalo2683 picture Gonzalo2683  Â·  3Comments

NathanKleekamp picture NathanKleekamp  Â·  3Comments

OmgImAlexis picture OmgImAlexis  Â·  3Comments

Benzenes picture Benzenes  Â·  3Comments