vue项目运行 $ npm run dev
报错如下:(原因是8080端口号被占用)

$ npm run dev

> sell1@1.0.0 dev E:\易先生\vue\Vue 高仿开发饿了么webApp\sell1
> node build/dev-server.js

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::8080
    at Object.exports._errnoException (util.js:1018:11)
    at exports._exceptionWithHostPort (util.js:1041:20)
    at Server._listen2 (net.js:1262:14)
    at listen (net.js:1298:10)
    at Server.listen (net.js:1394:5)
    at EventEmitter.listen (E:\易先生\vue\Vue 高仿开发饿了么webApp\sell1\node_modules\_express@4.15.3@express\lib\application.js:618:24)
    at Object.<anonymous> (E:\易先生\vue\Vue 高仿开发饿了么webApp\sell1\build\dev-server.js:92:22)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:393:7)
    at startup (bootstrap_node.js:150:9)
    at bootstrap_node.js:508:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sell1@1.0.0 dev: `node build/dev-server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sell1@1.0.0 dev script 'node build/dev-server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the sell1 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node build/dev-server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs sell1
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls sell1
npm ERR! 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\2017-07-28T06_52_21_274Z-debug.log

解决方法:
项目目录下build文件,=> config文件 =>index.js 进行修改如下:

  dev: {
    env: require('./dev.env'),
    port: 8000,                            // 将端口号修改成你想要修改的端口号
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    proxyTable: {},
    // CSS Sourcemaps off by default because relative paths are "buggy"
    // with this option, according to the CSS-Loader README
    // (https://github.com/webpack/css-loader#sourcemaps)
    // In our experience, they generally work as expected,
    // just be aware of this issue when enabling this option.
    cssSourceMap: false
  }
Logo

前往低代码交流专区

更多推荐