React-Native 文件 'expo-module-scripts/tsconfig.base' 找不到

问题描述 投票:0回答:3

我的问题是这样的

// @generated by expo-module-scripts
{
  "extends": "expo-module-scripts/tsconfig.base",
  "compilerOptions": {
    "outDir": "./build"
  },
  "include": ["./src"],
  "exclude": ["**/__mocks__/*", "**/__tests__/*", "**/__stories__/*"]
}

说明 要继承的基本配置文件的路径。需要 TypeScript 2.1 或更高版本。 找不到文件 'expo-module-scripts/tsconfig.base'.ts

reactjs typescript react-native visual-studio-code expo
3个回答
10
投票

我在另一个 expo 模块上也有这个错误,尝试重新启动 vs code,看看问题是否正确。 它对我有用,可能是一个 IDE 错误


0
投票

我的问题通过安装解决

 types/react-native

yarn add @types/react-native@~0.70.6

 npm install  @types/react-native@~0.70.6

这是我的 package.json:

 "@types/react-native": "~0.70.6",
    "expo": "~47.0.12",
    "expo-status-bar": "~1.4.4",
    "react": "18.1.0",
    "react-native": "0.70.5"

tsconfig.js 必须喜欢:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "forceConsistentCasingInFileNames": true,
    "isolatedModules": true,
    "lib": [
      "ESNext"
    ],
    "noEmitHelpers": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "strict": true,
    "jsx": "react-native"
  },
  "exclude": [
    "node_modules"
  ],
  "extends": "expo/tsconfig.base"
}

0
投票

我想也许 VSCode 无法同步新的 ts-config 文件。所以在我的例子中,我重新打开了 VSCode,它起作用了。

希望这个解决方案有帮助,抱歉我的英语不好。

© www.soinside.com 2019 - 2024. All rights reserved.