ffb*_*ord -1 javascript node.js npm vue.js
我刚刚安装了 Node.js 和 Vue.js,并在 Vue 上创建了我的第一个名为test 的项目。我现在正在尝试通过在 cmd 上键入来设置服务器:
npm run server
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
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
Run Code Online (Sandbox Code Playgroud)
谁能帮助我了解我缺少什么?我用谷歌搜索了一下,但到目前为止还没有找到解决方案。我很感激,任何帮助!
编辑:这是我的 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"
]
}
Run Code Online (Sandbox Code Playgroud)
小智 9
1-首先输入以下内容
vue add @vue/cli-service
Run Code Online (Sandbox Code Playgroud)
2-将以下代码添加到package.json(如果没有)
“脚本”:{“服务”:“vue-cli-service服务”,“构建”:“vue-cli-service构建”},
3- 类型代码 ==> npm runserve <=== 为服务或类型 ==> npm run build 为构建 <==
npm run serve
Run Code Online (Sandbox Code Playgroud)
或按照以下方式构建
npm run build
Run Code Online (Sandbox Code Playgroud)
如果不起作用,您只需运行以下命令并再次重复
npm install
npm init
Run Code Online (Sandbox Code Playgroud)
替换npm run server为npm run serve
在您package.json的scripts密钥下,您没有server脚本。但你确实有serve一个。要运行某个脚本,npm run 它需要scripts在您的内部package.json
| 归档时间: |
|
| 查看次数: |
10170 次 |
| 最近记录: |