0

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"
  ]
}
3
  • 1
    can you show your package.json file. Commented Feb 19, 2019 at 9:32
  • @MohammadRaheem I updated the question and included it Commented Feb 19, 2019 at 9:34
  • 2
    You should run: npm run serve, not server... Commented Feb 19, 2019 at 9:35

4 Answers 4

9

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
Sign up to request clarification or add additional context in comments.

Comments

8

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

Comments

3

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.

Comments

0

Just go to the right directory that contain :

.idea

node_modules

public

src .

.

.

and then write npm run serve again

Just this

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.