创建Expo项目时出现create-Expo应用程序错误



使用create-expo-app创建的Expo项目在使用expo start命令运行时会导致bundle错误。我在iOS上使用Expo Go(包括模拟器和物理设备(。

这种情况发生在空白项目和使用-t expo-template-blank-typescript标志和参数创建的typescript项目中。

其中一个依赖项显然找不到expo-constants模块。

环境

expo-env-info 1.0.5 environment info:
System:
OS: macOS 12.2.1
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 14.17.0 - ~/.nvm/versions/node/v14.17.0/bin/node
Yarn: 1.22.18 - ~/.nvm/versions/node/v14.17.0/bin/yarn
npm: 7.22.0 - ~/.nvm/versions/node/v14.17.0/bin/npm
Managers:
CocoaPods: 1.11.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
IDEs:
Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
npmPackages:
expo: ~45.0.0 => 45.0.8 
react: 17.0.2 => 17.0.2 
react-dom: 17.0.2 => 17.0.2 
react-native: 0.68.2 => 0.68.2 
react-native-web: 0.17.7 => 0.17.7 
npmGlobalPackages:
eas-cli: 0.56.0
expo-cli: 6.0.1
Expo Workflow: managed

错误

iOS Bundling failed 3713ms
Unable to resolve module expo-constants from path/to/my-app/node_modules/expo-asset/build/PlatformUtils.js: expo-constants could not be found within the project or in these directories:
node_modules
1 | import computeMd5 from 'blueimp-md5';
> 2 | import Constants from 'expo-constants';
|                        ^
3 | import * as FileSystem from 'expo-file-system';
4 | import { NativeModulesProxy } from 'expo-modules-core';
5 | import { getManifestBaseUrl } from './AssetUris';

npx create-expo-app安装的依赖项

"dependencies": {
"expo": "~45.0.0",
"expo-status-bar": "~1.3.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-native": "0.68.2",
"react-native-web": "0.17.7"
},
"devDependencies": {
"@babel/core": "^7.12.9"
},

我也有同样的问题,没有合适的解决方案,但这是一种变通方法。在expo start之前运行它。

expo install expo-constants expo-file-system expo-modules-core

相关内容

最新更新