为什么我在 Vue.js 上收到 npm missing server 错误?

新手上路,请多包涵

我刚刚安装了 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"
  ]
}

原文由 ffblord 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 700
2 个回答

npm run server 替换为 npm run serve

解释

在你的 package.jsonscripts 键你没有 server 脚本。但是您确实有一个 serve 一个。要使用 npm run 它需要在 scripts 你的 package.json

原文由 molamk 发布,翻译遵循 CC BY-SA 4.0 许可协议

1-首先输入以下内容

vue add @vue/cli-service

2-如果没有,将以下代码添加到 package.json

“scripts”: { “serve”: “vue-cli-service serve”, “build”: “vue-cli-service build” },

3- 输入代码 ==> npm run serve <=== for serve 或 type==> npm run build for build <==

 npm run serve

或跟随建立

npm run build

如果只是不起作用,你只需运行以下并再次重复

npm install

npm init

原文由 سعید دالوند 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
logo
Stack Overflow 翻译
子站问答
访问
宣传栏