Javascript 为什么Vue.js上出现npm缺少服务器错误?

Javascript 为什么Vue.js上出现npm缺少服务器错误?,javascript,node.js,vue.js,npm,Javascript,Node.js,Vue.js,Npm,我刚刚安装了Node.js和Vue.js,并在Vue上创建了第一个名为test的项目。我现在正试图通过键入cmd来设置服务器: npm run server 但我得到了以下错误: 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

我刚刚安装了Node.js和Vue.js,并在Vue上创建了第一个名为test的项目。我现在正试图通过键入cmd来设置服务器:

npm run server
但我得到了以下错误:

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
谁能帮我理解我错过了什么?我在谷歌上搜索了一下,但到目前为止还没有找到解决方案。谢谢你的帮助

编辑:这是我的package.json文件

{
  "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"
  ]
}
{
“名称”:“测试”,
“版本”:“0.1.0”,
“私人”:没错,
“脚本”:{
“服务”:“vue cli服务服务”,
“生成”:“vue cli服务生成”,
“lint”:“vue cli服务lint”
},
“依赖项”:{
“vue”:“^2.5.22”
},
“依赖性”:{
“@vue/cli插件巴别塔”:“^3.4.0”,
“@vue/cli插件eslint”:“^3.4.0”,
“@vue/cli服务”:“^3.4.0”,
“babel eslint”:“^10.0.1”,
“eslint”:“^5.8.0”,
“eslint插件vue”:“^5.0.0”,
vue模板编译器“^2.5.21”
},
“eslintConfig”:{
“根”:对,
“环境”:{
“节点”:true
},
“扩展”:[
“插件:vue/essential”,
“eslint:建议使用”
],
“规则”:{},
“解析选项”:{
“解析器”:“babel eslint”
}
},
“邮政编码”:{
“插件”:{
“自动引用器”:{}
}
},
“浏览者”:[
"> 1%",
“最后两个版本”,

“非ie用
npm运行服务替换
npm运行服务器

解释
程序包.json
中,在
脚本
键下,您没有
服务器
脚本。但是您有一个
服务
脚本。要使用
npm run运行某个脚本
它需要在
程序包内的
脚本中。json
在终端中的第一个类型:

npm install
npm start
npm run serve

我用这种方法解决了我的问题,它在我的电脑上运行得非常好。

1-首先键入以下内容

vue add @vue/cli-service
2-如果没有,请将以下代码添加到package.json

“脚本”:{ “服务”:“vue cli服务服务”, “生成”:“vue cli服务生成” },


3-类型代码==>npm运行服务npm运行构建只需转到包含以下内容的正确目录:

.想法

节点单元

公开的

src

然后再次编写npm运行服务


仅此

您能显示您的package.json文件吗。@MohammadRaheem我更新了问题并将其包括在内您应该运行:npm运行服务,而不是服务器。。。
npm run serve 
npm run build
npm install

npm init