生成构建时出错:[vite:load-fallback] 无法加载
2022-08-06
9603
问题似乎是我在
TypeScript
和
paths
(
alias
) 中设置了
baseUrl
。
typeScript 的配置
"baseUrl": ".",
"paths": {
"screens/*": ["./src/screens/*"],
"components/*": ["./src/components/*"]
}
为了使其正常工作,我还必须在
vite.config.ts
中配置
Vite
:
export default defineConfig({
plugins: [react()],
resolve:{
alias:{
screens: path.resolve(__dirname, './src/screens'),
components: 'src/components',
}
}
})
使用时
npm run build
生成以下错误:
[vite:load-fallback] Could not load src/components/tables/MainTable (imported by src/screens/Home.tsx): ENOENT: no such file or directory, open 'C:\Users\USER\Documents\proyect-test\src\components\tables\MainTable'
error during build:
Error: Could not load src/components/tables/MainTable (imported by src/screens/Home.tsx): ENOENT: no such file or directory, open 'C:\Users\USER\Documents\proyect-test\src\components\tables\MainTable'
这个项目很小,用作示例
1个回答
尝试将其更改为以下内容:
export default defineConfig({
plugins: [react()],
resolve:{
alias:{
screens: '/src/screens',
components: '/src/components',
}
}
})
Schotime
2022-08-18