admin管理员组

文章数量:1237497

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 plete 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-piler": "^2.5.21"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:remended"
    ],
    "rules": {},
    "parserOptions": {
      "parser": "babel-eslint"
    }
  },
  "postcss": {
    "plugins": {
      "autoprefixer": {}
    }
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ]
}

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 plete 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-piler": "^2.5.21"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:remended"
    ],
    "rules": {},
    "parserOptions": {
      "parser": "babel-eslint"
    }
  },
  "postcss": {
    "plugins": {
      "autoprefixer": {}
    }
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ]
}
Share Improve this question edited Feb 19, 2019 at 9:33 ffblord asked Feb 19, 2019 at 9:28 ffblordffblord 4133 gold badges7 silver badges14 bronze badges 3
  • 1 can you show your package.json file. – Mohammad Raheem Commented Feb 19, 2019 at 9:32
  • @MohammadRaheem I updated the question and included it – ffblord Commented Feb 19, 2019 at 9:34
  • 2 You should run: npm run serve, not server... – Paolo Commented Feb 19, 2019 at 9:35
Add a ment  | 

4 Answers 4

Reset to default 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

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

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.

Just go to the right directory that contain :

.idea

node_modules

public

src .

.

.

and then write npm run serve again

Just this

本文标签: javascriptWhy am I getting an npm missing server error on VuejsStack Overflow