EISDIR: illegal operation on a directory, read

中弹了
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" }]
}

文档在不断的改进中!!!敬请谅解

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值