Our project is utilizing the expo-cli as a local dependency in order to execute build:web from an npm script without requiring the global installation of expo-cli. However, when we run npm run build:web
, we encounter the following exception.
To isolate the issue, we created a basic TypeScript project using expo init and then performed npm install expo-cli -D
. Interestingly, everything worked fine without TypeScript, leading us to suspect that TypeScript might be causing the problem.
The error occurs during the build process:
>>npm run build:web
> @ build:web /home/anna/examplets
> expo build:web
(node:24316) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'replace' of undefined
at Object.<anonymous> (/home/anna/examplets/node_modules/@expo/webpack-config/src/withWorkbox.ts:142:10)
at Generator.next (<anonymous>)
at fulfilled (/home/anna/examplets/node_modules/@expo/webpack-config/webpack/withWorkbox.js:4:58)
(node:24316) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:24316) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Output provided by expo-diagnostics
:
Expo CLI 3.4.1 environment info:
System:
OS: Linux 4.15 Ubuntu 18.04.3 LTS (Bionic Beaver)
Shell: 4.4.20 - /bin/bash
Binaries:
Node: 10.16.2 - ~/.nvm/versions/node/v10.16.2/bin/node
Yarn: 1.19.1 - /usr/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v10.16.2/bin/npm
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5900203
npmPackages:
@types/react: ^16.8.23 => 16.9.11
@types/react-native: ^0.57.65 => 0.57.65
expo: ^35.0.0 => 35.0.0
react: 16.8.3 => 16.8.3
react-native: https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz => 0.59.8
This is our package.json
configuration:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject",
"build:web": "expo build:web"
},
"dependencies": {
"expo": "^35.0.0",
"react": "16.8.3",
"react-dom": "16.8.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",
"react-native-web": "^0.11.7"
},
"devDependencies": {
"@types/react": "^16.8.23",
"@types/react-native": "^0.57.65",
"babel-preset-expo": "^7.1.0",
"expo-cli": "^3.4.1",
"typescript": "^3.6.3"
},
"private": true
}