关于vue使用 npm run dev报错原因

Posted smile-tianxia

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于vue使用 npm run dev报错原因相关的知识,希望对你有一定的参考价值。

> my-project@0.1.0 dev D:my-project
> webpack-dev-server --inline --progress --config build/webpack.dev.conf.js

internal/modules/cjs/loader.js:796
    throw err;
    ^

Error: Cannot find module D:my-projectuildwebpack.dev.conf.js
Require stack:
- D:my-project
ode_moduleswebpack-cliinutilsconvert-argv.js
- D:my-project
ode_moduleswebpack-dev-serverinwebpack-dev-server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
    at Function.Module._load (internal/modules/cjs/loader.js:686:27)
    at Module.require (internal/modules/cjs/loader.js:848:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at WEBPACK_OPTIONS (D:my-project
ode_moduleswebpack-cliinutilsconvert-argv.js:114:13)
    at requireConfig (D:my-project
ode_moduleswebpack-cliinutilsconvert-argv.js:116:6)
    at D:my-project
ode_moduleswebpack-cliinutilsconvert-argv.js:123:17
    at Array.forEach (<anonymous>)
    at module.exports (D:my-project
ode_moduleswebpack-cliinutilsconvert-argv.js:121:15)
    at Object.<anonymous> (D:my-project
ode_moduleswebpack-dev-serverinwebpack-dev-server.js:84:40) {
  code: MODULE_NOT_FOUND,
  requireStack: [
    D:my-project
ode_moduleswebpack-cliinutilsconvert-argv.js,
    D:my-project
ode_moduleswebpack-dev-serverinwebpack-dev-server.js
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-project@0.1.0 dev: `webpack-dev-server --inline --progress --config build/webpack.dev.conf.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-project@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:UsersAdministratorAppDataRoaming
pm-cache\\_logs2020-02-14T13_27_31_418Z-debug.log

打开package.js文件夹如下:

{
  "name": "my-project",
  "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",
    "webpack-cli": "^3.3.10"
  },
  "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"
  ]
}

发现vue 给咱们提供的启动方式为serve

于是找到问题所在运行 npm run serve  果然运行成功 如图:

技术图片

 

以上是关于关于vue使用 npm run dev报错原因的主要内容,如果未能解决你的问题,请参考以下文章

Vue 项目在其他电脑 npm run dev 运行报错的解决方法

详解Vue项目在其他电脑npm run dev运行报错的解决方法

vue cli 使用npm run dev 报错Cannot GET /

vue项目,npm install后,npm run dev报错问题

使用vue-cli初始化项目时运行‘npm run dev’报错

vue项目npm run dev报错events.js:160 throw er; // Unhandled 'error' event listen EADDRINUSE