我刚刚安装了 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 许可协议
将
npm run server
替换为npm run serve
解释
在你的
package.json
下scripts
键你没有server
脚本。但是您确实有一个serve
一个。要使用npm run
它需要在scripts
你的package.json