ffblord
ffblord

Reputation: 413

Why am I getting an npm missing server error on Vue.js?

I just installed Node.js and Vue.js and created my first project on Vue called test . I am now trying to set up the server by typing on cmd:

npm run server

But I get the following error:

C:\Users\andri\test>npm run server
npm ERR! missing script: server

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\andri\AppData\Roaming\npm-cache\_logs\2019-02-19T09_12_53_961Z-debug.log

Could anyone help me understand what I am missing? I googled a bit around, but have not been able to find a solution so far. I appreciate, any help!

EDIT: This is my package.json file

{
  "name": "test",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "vue": "^2.5.22"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^3.4.0",
    "@vue/cli-plugin-eslint": "^3.4.0",
    "@vue/cli-service": "^3.4.0",
    "babel-eslint": "^10.0.1",
    "eslint": "^5.8.0",
    "eslint-plugin-vue": "^5.0.0",
    "vue-template-compiler": "^2.5.21"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "rules": {},
    "parserOptions": {
      "parser": "babel-eslint"
    }
  },
  "postcss": {
    "plugins": {
      "autoprefixer": {}
    }
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ]
}

Upvotes: 1

Views: 27669

Answers (4)

Mehdi Rokhsati
Mehdi Rokhsati

Reputation: 69

Just go to the right directory that contain :

.idea

node_modules

public

src .

.

.

and then write npm run serve again

Just this

Upvotes: 0

سعید دالوند
سعید دالوند

Reputation: 155

1- type the folowing first

vue add @vue/cli-service

2- add following code to package.json if there were not

"scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build" },

3- type code ==> npm run serve <=== for serve or type==> npm run build for build <==

npm run serve 

or following to build

npm run build

if only doesnt work you just run following and reapeat again

npm install

npm init

Upvotes: 9

Njena
Njena

Reputation: 301

First type in your terminal:

npm install
npm start
npm run serve

I solved my problem this way and it works perfectly on my PC.

Upvotes: 3

molamk
molamk

Reputation: 4116

Replace npm run server with npm run serve

Explanation

In your package.json under the scripts key you don't have a server script. But you do have a serve one. To run a certain script with npm run it needs to be in scripts inside your package.json

Upvotes: 8

Related Questions