How to solve 'vue-cli-service' is not recognized as an internal or external command?

前端 未结 8 1248
北海茫月
北海茫月 2021-01-03 18:07

I am getting an error when trying to run npm run serve. At first I installed node.js then vue as well as vue/cli. But when I am trying to run server as -> npm r

相关标签:
8条回答
  • 2021-01-03 18:37

    it will depend on package manager you are using

    1. if you are using yarn run yarn or yarn install and then yarn serve
    2. if you are using npm run npm install and then npm run serve
    0 讨论(0)
  • 2021-01-03 18:42

    In my case, the package @vue/cli-service is installed in my local node_modules environment, but not my global environment, so it cannot be used as a command. I type .\node_modules\.bin\vue-cli-service serve and it works.

    0 讨论(0)
  • 2021-01-03 18:43

    As it is mentioned in terminal that node_modules is missing from your project, so you can't directly use npm run serve, first you have to do npm install then do npm run serve. It will work fine

    0 讨论(0)
  • 2021-01-03 18:44

    I think you are using cmd in windows.

    Try deleting the node_modules folder and after that run npm i from the cmd.

    Then try running npm run serve again and see if it works this time

    0 讨论(0)
  • 2021-01-03 18:44
    npm install @vue/cli-service -g
    

    This will install global npm package.

    @vue/cli-service is usully installed as global, because you do not usually copy these types of packages to every project.

    If the global npm package gets corrupted, it is not stored in node_modules folder, but rather in other depending on the os. Therefore removing node_modules does not help. Locations for global node_modules folders are %USERPROFILE%\AppData\Roaming\npm\node_modules (Win10) or /usr/local/lib/node_modules (Linux) Check this stack overflow post on how to locate global packages.

    0 讨论(0)
  • 2021-01-03 18:45

    I had faced the same problem in windows. Then first I deleted the node_module. then I run npm install.

    0 讨论(0)
提交回复
热议问题