当前位置: 首页 > article >正文

运行前端项目报错解决方法

在运行项目是npm run dev
运行到最后报一下错误

DONE  Compiled successfully in 11178ms                                  
  App running at:
  - Local:   http://localhost:80
  - Network: unavailable

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

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

Error: spawn cmd ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn cmd',
  path: 'cmd',
  spawnargs: [ '/c', 'start', '""', '/b', 'http://localhost:80' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app@0.1.0 serve: `vue-cli-service serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the app@0.1.0 serve 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!     D:\node\node_cache\_logs\2020-12-19T07_42_04_693Z-debug.log

解决方法:
原因: 电脑缺少cmd运行程序的环境变量
按如图设置cmd的环境变量,然后重启vscode即可。
在这里插入图片描述
解决 Network: unavailable
在vite.config.js

module.exports = {

    configureWebpack: {

        // other webpack options to merge in ...

    },

    // devServer Options don't belong into `configureWebpack`

    devServer: {

        public: '120.0.0.0:8080',//这里的ip地址换成本机的ip地址

        hot: true,

        disableHostCheck: true,

    }



};


http://www.kler.cn/a/611580.html

相关文章:

  • 游戏引擎学习第184天
  • MTK Android15 去掉设置中的顶部空白
  • 苹果与安卓,鸿蒙下跨设备,应用分享
  • 12届蓝桥杯—货物摆放
  • 【软件工程】简答题
  • 开源软件许可证冲突的原因和解决方法
  • ZW3D二次开发_非模板表单_控件_添加回调
  • Leetcode12-整数转罗马数字
  • 数据库基础知识点(系列七)
  • 【开题报告+论文+源码】基于SpringBoot的智能安全与急救知识科普系统设计与实现
  • 【后端】【Django DRF】从零实现RBAC 权限管理系统
  • Ubuntu22.04搭建freeradius操作说明
  • Java基础 3.22
  • 深度学习入门1 基于Python的理论与实现
  • 如何在 Postman 中发送 DELETE 请求?
  • ngx_conf_handler - root html
  • GPT Researcher 的win docker安装攻略
  • unity泛型对象池
  • Elasticsearch:使用 AI SDK 和 Elastic 构建 AI 代理
  • JVM