首页 > 解决方案 > page/Activity/ActivityTable ✖ 找不到包“page/Activity/ActivityTable”。你安装了吗?当我使用雪包开发时

问题描述

也许这是一个tsconfig问题,但我不知道什么是正确的。我使用模板app-template-react-typescript,我发现当我使用src/page它时它可以工作。

这是我的 tsconfig

{
  "include": ["src", "types"],
  "exclude": ["node_modules"],
  "extends": "@snowpack/app-scripts-react/tsconfig.base.json",
  "compilerOptions": {
    // You can't currently define paths in your 'extends' config,
    // so we have to set 'baseUrl' & 'paths' here.
    // Don't change these unless you know what you're doing.
    // See: https://github.com/microsoft/TypeScript/issues/25430
    "experimentalDecorators": true,
    "baseUrl": "./",
    "paths": {
      "stylesheet/*": ["src/asset/stylesheet/*"],
      "image/*": ["src/asset/image/*"],
      "shared/*": ["src/shared/*"],
      "layout/*": ["src/layout/*"],
      "component/*": ["src/component/*"],
      "page/*": ["src/page/*"],
      "utils/*": ["src/utils/*"],
      "constant/*": ["src/constant/*"],
      "store/*": ["src/store/*"],
      "src/*":["src/*"]
    }
    // Feel free to add/edit new config options below:
    // ...
  }
}

标签: reactjstypescriptsnowpack

解决方案


已经得到 snowpack 团队的回答,他们说:我们目前不支持 TSConfig 路径,但我们有一个 PR 要添加:pikapkg/snowpack#432 在那之前,您需要通过“src/page/Account”导入让 Snowpack 正确识别它

所以我会关闭这个问题并暂时使用'src/page/Account'来解决我的问题


推荐阅读