![](/img/trans.png)
[英]why am i getting 'i is not defined' error from a simple for loop in vue.js component script?
[英]Why am I getting an npm missing server error on Vue.js?
我刚刚安装了 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"
]
}
更换npm run server
与npm run serve
在scripts
键下的package.json
,您没有server
脚本。 但你确实有一个serve
。 要使用npm run
运行某个脚本,它需要在package.json
中的scripts
首先在你的终端输入:
npm install
npm start
npm run serve
我以这种方式解决了我的问题,它在我的 PC 上完美运行。
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 or type==> npm run build for build <==
npm run serve
或以下构建
npm run build
如果只是不起作用,您只需运行以下并再次重复
npm install
npm init
只需转到包含以下内容的正确目录:
。主意
节点模块
民众
源文件。
.
.
然后再次编写 npm run serve
只是这个
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.