中弹了
EISDIR: illegal operation on a directory, read
Click outside or fix the code to dismiss.
You can also disable this overlay by setting server.hmr.overlay to false in vite.config.js.
vite4
解决方案一
解决方案最好是去GitHub上看,提示我是在vite.config.js,所以看config
我当前的解决方法是抄袭官网的
// vite.config.js
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import alias from '@rollup/plugin-alias';
import resolve from '@rollup/plugin-node-resolve';
const customResolver = resolve({
extensions: ['.mjs', '.js', '.jsx', '.json', '.sass', '.scss']
});
const projectRootDir = path.resolve(__dirname);
export default defineConfig({
//选项配置
plugins: [
vue(),
alias({
entries: [
{
find: 'src',
replacement: path.resolve(projectRootDir, 'src')
// OR place `customResolver` here. See explanation below.
},
{ find: 'utils', replacement: '../../../utils' },
{ find: '@', replacement: '../../src' },
],
customResolver
}),
resolve()
],
})
错误提示如下
所以英文可以和我一样不会,但单词的形状我们可以记住。平时可以多冲英文网。
解决方案二
安装path
npm install path
在文件中添加如下内容
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import * as path from "path";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src')
}
},
})
在文件中新增如下内容
"paths": {
"@/*": ["src/*"]
}
添加后
/*tsconfig.json*/
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
},
"include": [
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue",
"node_modules/@vue/runtime-core/dist/runtime-core.d.ts",
"node_modules/@vue/runtime-core/dist/runtime-core.d.ts"
],
"references": [{ "path": "./tsconfig.node.json" }]
}
文档在不断的改进中!!!敬请谅解