package.json

可在 package.json 文件中使用的 Expo 特定属性的参考。


package.json 是一个 JSON 文件,其中包含 JavaScript 项目的元数据。这是对可在 package.json 文件中使用的 Expo 特定属性的引用。

¥package.json is a JSON file that contains the metadata for a JavaScript project. This is a reference to Expo-specific properties that can be used in the package.json file.

install.exclude

以下命令对项目中安装的库执行版本检查,并在库的版本与 Expo 推荐的版本不同时发出警告:

¥The following commands perform a version check for the libraries installed in a project and give a warning when a library's version is different from the version recommended by Expo:

  • npx expo startnpx expo-doctor

    ¥npx expo start and npx expo-doctor

  • npx expo install(安装该库的新版本或使用 --check--fix 选项时)

    ¥npx expo install (when installing a new version of that library or using --check or --fix options)

通过在 package.json 文件中的 install.exclude 数组下指定库,你可以将其排除在版本检查之外:

¥By specifying the library under the install.exclude array in the package.json file, you can exclude it from the version checks:

package.json
{
"expo": {
  "install": {
    "exclude": ["expo-updates", "expo-splash-screen"]
  }
}
}

autolinking

允许使用 package.json 中的 autolinking 属性配置模块解析行为。

¥Allows configuring module resolution behavior by using autolinking property in package.json.

有关完整参考,请参阅 自动链接配置

¥For complete reference, see Autolinking configuration.

doctor

允许配置 npx expo-doctor 命令的行为。

¥Allows configuring the behavior of the npx expo-doctor command.

reactNativeDirectoryCheck

默认情况下,Expo Doctor 会根据 React Native 目录 验证你项目的包。此检查会抛出一个警告,其中包含 React Native 目录中未包含的软件包列表。

¥By default, Expo Doctor validates your project's packages against the React Native directory. This check throws a warning with a list of packages that are not included in the React Native Directory.

你可以通过在项目的 package.json 文件中添加以下配置来自定义此检查:

¥You can customize this check by adding the following configuration in your project's package.json file:

package.json
{
"expo": {
"doctor": {
  "reactNativeDirectoryCheck": {
    "enabled": true,
    "exclude": ["/foo/", "bar"],
    "listUnknownPackages": true
  }
}
}
}

默认情况下,检查已启用并列出未知包。

¥By default, the check is enabled and unknown packages are listed.

appConfigFieldsNotSyncedCheck

Expo Doctor 检查你的项目是否包含原生项目目录,例如 android 或 ios。如果这些目录存在但未在你的 .gitignore 或 .easignore 文件中列出,Expo Doctor 会验证应用配置文件的存在。如果此文件存在,则表示你的项目已配置为使用 预建

¥Expo Doctor checks if your project includes native project directories such as android or ios. If these directories exist but are not listed in your .gitignore or .easignore files, Expo Doctor verifies the presence of an app config file. If this file exists, it means your project is configured to use Prebuild.

当存在 android 或 ios 目录时,EAS Build 不会将应用配置属性同步到原生项目。如果这些条件成立,Expo Doctor 会发出警告。

¥When the android or ios directories are present, EAS Build does not sync app config properties to the native projects. Expo Doctor throws a warning if these conditions are true.

你可以通过将以下配置添加到项目的 package.json 文件中来禁用或启用此检查:

¥You can disable or enable this check by adding the following configuration to your project's package.json file:

package.json
{
"expo": {
"doctor": {
  "appConfigFieldsNotSyncedCheck": {
    "enabled": false
  }
}
}
}