报错内容:

> vue-admin-template@4.4.0 dev
> vue-cli-service serve

 INFO  Starting development server...
98% after emitting CopyPlugin

 DONE  Compiled successfully in 6995ms                       15:25:13


  App running at:
  - Local:   http://localhost:9528/
  - Network: unavailable

  Note that the development build is not optimized.
  To create a production build, run npm run build. 

node:events:504
      throw er; // Unhandled 'error' event
      ^

Error: spawn cmd ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:8Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn cmd',
  path: 'cmd',
  spawnargs: [ '/c', 'start', '""', '/b', 'http://localhost:9528/' ] 
}

显示下列报错

node:events:504
      throw er; // Unhandled 'error' event
      ^

可以将vue.config.js文件中,

devServer: {
    port: port,
    open: open,
    overlay: {
      warnings: false,
      errors: true
    },
    before: require('./mock/mock-server.js')
  },

将其中的:    open:open,

改成:           open:false,

该语句作用是告诉dev-server在服务器启动后打开浏览器,

改完以后就可以通过打开本地端口进行访问了。

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐