环境安装:
从 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