The Problem:
A React Native web application is experiencing an error while attempting to launch in a web context. The error message "10%Error: error:0308010C:digital envelope routines::unsupported" appears. The issue is encountered when choosing "w-web" as the target platform for the application. The user has provided their package.json file, which includes a script to start the web version of the application, along with the node.js version being used. The task is to determine the cause of this error and provide a solution to resolve it.
The Solutions:
Solution 1: Use the –openssl-legacy-provider flag
The error is caused by a version incompatibility between Node.js and OpenSSL. To resolve it, you can use the --openssl-legacy-provider
flag in your package.json
file. This flag sets up a compatibility layer between Node.js and OpenSSL, allowing them to work together seamlessly.
Here’s how to use the flag:
"scripts": {
"start": "expo start --openssl-legacy-provider",
...
}
After adding this flag, try running expo start --web
again. The error should be resolved.
Additional Tips:
1. Ensure that expo
is installed in your project by running npm install expo
or yarn add expo
(if not already done).
2. If you encounter an error like Error: Cannot find module 'expo/config'
, ensure that the expo
module is correctly referenced. Use require('@expo/config')
instead of require('expo/config')
. You can find the file at *"AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\webpack-config\webpack\env"*
.
Q&A
How to resolve error 0308010C:digital envelope routines::unsupported?
Use the –openssl-legacy-provider flag in the package.json’s start script.
What to do if I get Cannot find module ‘expo/config’ error?
Make sure expo is installed. If it is, update module reference to ‘@expo/config’.
Video Explanation:
The following video, titled "Related Video", provides additional insights and in-depth exploration related to the topics discussed in this post.
Here are two options now - 1. Try to uninstall Node.js version 17+ and reinstall Node.js version 16+ You can re-install the current LTS ...
The following video, titled "Related Video", provides additional insights and in-depth exploration related to the topics discussed in this post.
Here are two options now - 1. Try to uninstall Node.js version 17+ and reinstall Node.js version 16+ You can re-install the current LTS ...