【发布时间】:2020-05-28 06:41:41
【问题描述】:
我正在尝试运行我的第一个应用程序。我从 CLI 创建了它: vue create hello-world
当我尝试使用 CLI 启动应用程序时:npm run serve 应用程序运行。
当我尝试使用 CLI 启动应用程序时:npm run dev 应用程序返回以下错误。
PS C:\Users\Administrator\hello-world> npm install -g npm@latest
C:\Users\Administrator\AppData\Roaming\npm\npx -> C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\bin\npx-cli.js
C:\Users\Administrator\AppData\Roaming\npm\npm -> C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
+ npm@6.13.7
added 434 packages from 860 contributors in 14.601s
PS C:\Users\Administrator\hello-world> npm run dev
npm ERR! missing script: dev
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2020-02-12T16_06_26_201Z-debug.log
这是我的 packagejson:
{
"name": "hello-world",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.6.4",
"vue": "^2.6.11"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^4.2.0",
"@vue/cli-plugin-eslint": "^4.2.0",
"@vue/cli-service": "^4.2.0",
"babel-eslint": "^10.0.3",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.1.2",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions"
]
}
PS C:\Users\Administrator
我还尝试将新行放入我的 package.json 中:"dev": "vue-cli-service dev"
但我收到此错误:
> vue-cli-service dev
ERROR command "dev" does not exist.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hello-world@0.1.0 dev: `vue-cli-service dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hello-world@0.1.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2020-02-12T16_23_48_785Z-debug.log
【问题讨论】:
-
您希望
npm run dev做什么? -
我只是在学习一个网络教程,它告诉我运行这个命令。
-
本教程使用的是最新版本的 CLI 吗?我怀疑您只需要改用
npm run serve。在不知道dev应该做什么的情况下,很难进一步推测。