vite-plugin-mock icon indicating copy to clipboard operation
vite-plugin-mock copied to clipboard

error: Could not resolve "node:fs" (mark it as external to exclude it from the bundle)

Open xiuyuan-wang opened this issue 2 years ago • 6 comments

image

运行报错 "vite": "^3.0.9", "vite-plugin-mock": "^2.9.6", "typescript": "~4.7.4"

image

xiuyuan-wang avatar Oct 01 '22 06:10 xiuyuan-wang

不是 node 是 @vue/tsconfig/tsconfig.web.json

xiuyuan-wang avatar Oct 01 '22 06:10 xiuyuan-wang

有什么好的解决方案了吗

Miofly avatar Oct 09 '22 14:10 Miofly

有解决方法吗 遇到了同样的问题

Sasayah01 avatar Oct 18 '22 02:10 Sasayah01

好像是mock文件导致的,把mock文件里

// import { MockMethod } from 'vite-plugin-mock'
// 改成
import type { MockMethod } from 'vite-plugin-mock'

ghostoy avatar Oct 21 '22 01:10 ghostoy

我是因为从vite导入了loadEnv导致的,目前只能注释掉写死

// import { loadEnv } from 'vite'

kortin99 avatar Jan 03 '23 03:01 kortin99

改成这个就能解决 import type { MockMethod } from 'vite-plugin-mock'

clarehjh avatar Mar 20 '23 09:03 clarehjh