package.json

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


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

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 install(在安装该库的新版本或使用 --check--fix 选项时)

通过在 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 会检查你的项目是否包含原生项目目录,例如 androidios。如果这些目录存在但未列在你的 .gitignore.easignore 文件中,Expo Doctor 会验证应用配置文件的存在。如果该文件存在,则意味着你的项目已配置为使用 Prebuild

🌐 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.

当存在 androidios 目录时,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 } } } }