0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【React Native】npx expo startしたらReferenceError: ReadableStream is not definedと怒られた話

Last updated at Posted at 2025-02-15

概要

下記を参考にReact Native (Expo)の環境構築をしていた時に
色々怒られまくってやっとこさ環境ができた話です。

経緯

npx expo startを実施すると以下エラーが出て怒られた。。。

ReferenceError: ReadableStream is not defined
    at Object.<anonymous> (/Users/user/Desktop/sample-app/node_modules/undici/lib/web/fetch/response.js:528:3)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/user/Desktop/sample-app/node_modules/undici/lib/web/fetch/index.js:11:5)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
npm notice 
npm notice New major version of npm available! 7.24.0 -> 11.1.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.1.0
npm notice Run npm install -g npm@11.1.0 to update!
npm notice 

ここから対応していくのですが、更にエラーが出まくりました。
そのため、出力エラー順に対応した内容を記載してます。

エラーその1

下の方に

npm notice Run npm install -g npm@11.1.0 to update!

と出ている。
どうやらnpmのバージョンが古かったみたい。

そこでnpm install -g npm@11.1.0 を言われた通りに実施。

エラーその2

すると今度は、

npm ERR! code EBADENGINE
npm ERR! engine Unsupported engine
npm ERR! engine Not compatible with your version of node/npm: npm@11.1.0
npm ERR! notsup Not compatible with your version of node/npm: npm@11.1.0
npm ERR! notsup Required: {"node":"^20.17.0 || >=22.9.0"}
npm ERR! notsup Actual:   {"npm":"7.24.0","node":"v16.10.0"}

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/user/.npm/_logs/2025-02-07T14_58_49_534Z-debug.log

と怒られた…
これまた下の方に

npm ERR! notsup Required: {"node":"^20.17.0 || >=22.9.0"}
npm ERR! notsup Actual:   {"npm":"7.24.0","node":"v16.10.0"}

とあり、現在のNode.jsnバージョンは"node":"v16.10.0"であるのに対し、
求められているのは{"node":"^20.17.0 || >=22.9.0"}とのこと。
そこで、Node.jsごとアップデートすることにした。

下記コマンドをターミナルで実施して、
Node.jsのバージョンアップデートを実施。

brew update
brew upgrade nodebrew
nodebrew install-binary v20.17.0
nodebrew use v20.17.0

↑を実施後はバージョン確認。

node -v
> v20.17.0

npm --version
> 10.8.2

バージョンが上がっているので、
npx expo startを再び実施。

※以下参考とさせていただきました🙇‍♂️

エラーその3

また怒られました…
今度は

Error: The required package `expo-asset` cannot be found
    at getAssetPlugins (/Users/user/Desktop/sample-app/node_modules/@expo/metro-config/src/ExpoMetroConfig.ts:65:11)
    at getDefaultConfig (/Users/user/Desktop/sample-app/node_modules/@expo/metro-config/src/ExpoMetroConfig.ts:373:21)
    at loadMetroConfigAsync (/Users/user/Desktop/sample-app/node_modules/@expo/cli/src/start/server/metro/instantiateMetro.ts:96:43)
    at instantiateMetroAsync (/Users/user/Desktop/sample-app/node_modules/@expo/cli/src/start/server/metro/instantiateMetro.ts:195:53)
    at MetroBundlerDevServer.startImplementationAsync (/Users/user/Desktop/sample-app/node_modules/@expo/cli/src/start/server/metro/MetroBundlerDevServer.ts:940:69)
    at MetroBundlerDevServer.startAsync (/Users/user/Desktop/sample-app/node_modules/@expo/cli/src/start/server/BundlerDevServer.ts:160:18)
    at DevServerManager.startAsync (/Users/user/Desktop/sample-app/node_modules/@expo/cli/src/start/server/DevServerManager.ts:184:7)

と出た…
どうやら、
expo-assetなるものが見つからないようだ。

以下によるとnpx expo instalでモジュールをインストールできるとのこと。

そこで

npx expo install expo-asset

を実施し、expo-assetのインストールに成功。

やっと解決

再びnpx expo startを実施。
3度目?の正直で無事動作しました!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?