React-TypeScript-Snowpack 中的路径映射问题

问题描述

我在一个项目中使用 React、TypeScript 和 Snowpack。我在路径映射方面遇到问题。

这是我项目中的文件夹结构:

enter image description here

tsconfig.json

enter image description here

snowpack.coonfig.js

enter image description here

App.tsx

enter image description here

这是我得到的错误:

enter image description here

谁能帮我解决这个问题?我在这里缺少什么? 如果在 App.tsx 中,我在 ctrl+click 导入时HomePage,它会将我带到该页面,但是当我运行 yarn start 时,它会出现上述错误。

解决方法

您可能还需要将“app”别名添加到 snowpack 配置中,以便其识别。

https://www.snowpack.dev/reference/configuration#alias

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...