You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Remix Vite项目中路径别名无法生效的问题求助

Remix Vite项目中路径别名无法生效的问题求助

各位大佬好,我碰到个头疼的问题:我在tsconfig.json里配置了路径别名,但Remix就是识别不了😭

先给大家看看我的项目结构:

root
  └app
    └routes
      └_index.tsx
      └components
        └success.tsx

我的tsconfig.json配置(内容有部分截断)是这样的:

{
  "include": [
    "remix.env.d.ts",
    "**/*.ts",
    "**/*.tsx",
    "**/.server/**/*.ts",
    "**/.server/**/*.tsx",
    "**/.client/**/*.ts",
    "**/.client/**/*.tsx"
  ],
  "compilerOptions": {
    "lib": ["DOM", "DOM.Iterable", "ES2022"],
    "types": ["@remix-run/node", "vite/client"],
    "isolatedModules": true,
    "esModuleInterop": true,
    "jsx": "react-jsx",
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "resolveJsonModule": true,
    "target": "ES2022",
    // 这里是我配置别名的相关内容,比如baseUrl和paths,但原内容未完整显示
    ...
  }
}

我本来想用别名来导入success.tsx组件,比如类似import Success from '~/components/success'这种写法,但Remix一直报错说找不到模块。有没有朋友遇到过类似的情况?麻烦帮我排查下问题出在哪,感激不尽!

备注:内容来源于stack exchange,提问作者melontart

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.17 08:47:59