Vue3 + Vite3 工程搭建杂记

环境安装:
从 0 搭建 Vite 3 + Vue 3 前端工程化项目

  • node升级:
    # 使用 nvm 安装最新稳定版 Node.js nvm install stable

  • 配置了eslint保存自动fix,在保存的时候会一直卡住:正在保存“AboutView.vue”: 从 “‘Vetur’, ‘ESLint’, ‘Vue Language Features (Volar)’” (configure)中获取代码操作。
    可以降低Vetur版本试试

  • vue3框架搭建配置出现Unable to resolve path to module ‘@/xxx‘ eslint 错误解决办法

  • error Resolve error: unable to load resolver “alias”

    npm install eslint-import-resolver-alias -D 
    
    
  • error ‘vite’ should be listed in the project’s dependencies, not devDependencies
    -模块导入导出 使用模式不同导致配置文件找不到报错:
    require() of ES Module /Users/xtn/vite-vue-js-template/.cz-config.js from /Users/xtn/vite-vue-js-template/node_modules/find-config/src/find-config.js not supported.
    .cz-config.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains “type”: “module” which declares all .js files in that package scope as ES modules.
    Instead rename .cz-config.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change “type”: “module” to “type”: “commonjs” in /Users/xtn/vite-vue-js-template/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
    原因是配置文件.cz-config.js种用的是module.exports={} CommonJS 模式,而在package.json声明的为 “type”: “module”,即原生ES6模式,解决方案一个是将.cz-config.js 改为 .cz-config.cjs, 然后在package.json中修改模块应用的文件名:

    "config": {
        "commitizen": {
          "path": "./node_modules/cz-customizable"
        },
        "cz-customizable": {
          "config": "./.cz-config.cjs"	// 此处可以改成自己定义的文件名
        }
      }
    

    另一种方式就是修改package.json中"type": “module” to “type”: “commonjs”,这种没有尝试,感觉会影响现有代码中的import 和 export

  • github master 分支切换到main分支

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值