I was trying to get an Android-only React Native app running, but I kept coming across this error. It was apparently introduced in Node.js 17, as described in the release notes for that version. I tried the solutions that I found from a quick Google search but didn’t have much success:

  • Setting NODE_OPTIONS=--openssl-legacy-provider didn’t work since npm complained that the value was not allowed;
  • Using nvm to ensure I was using the appropriate Node.js version for the project (14) didn’t work.

I then decided to use nvm list to check which versions were available, and noticed I had Node.js 18 installed, but it wasn’t set as the current version (which was expected, since I had used nvm use before). However, the package.json script I was running called the globally installed node, and for some reason, it wasn’t respecting the version set by nvm; it seems it was using Node.js 18. Although there was probably a more elegant way to deal with this, temporarily deleting the offending version did the trick.