You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native启动Metro打包器失败:resp.asserted-states不可迭代错误

React Native Metro打包器启动失败(Windows 11环境)

问题场景

按照官方流程创建新React Native项目,在Windows 11系统(NodeJS 18.16.1)下执行npm start时,Metro打包器无法启动,抛出TypeError: resp.asserted-states is not iterable错误。相同NodeJS版本在WSL环境下可正常运行。

报错信息

PS D:\Sources\Personal\AwesomeProject> npm start

> AwesomeProject@0.0.1 start
> react-native start

                        ▒▒▓▓▓▓▒▒
                     ▒▓▓▓▒▒░░▒▒▓▓▓▒
                  ▒▓▓▓▓░░░▒▒▒▒░░░▓▓▓▓▒
                 ▓▓▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▓▓
                 ▓▓░░░░░▒▓▓▓▓▓▓▒░░░░░▓▓
                 ▓▓░░▓▓▒░░░▒▒░░░▒▓▒░░▓▓
                 ▓▓░░▓▓▓▓▓▒▒▒▒▓▓▓▓▒░░▓▓
                 ▓▓░░▓▓▓▓▓▓▓▓▓▓▓▓▓▒░░▓▓
                 ▓▓▒░░▒▒▓▓▓▓▓▓▓▓▒░░░▒▓▓
                  ▒▓▓▓▒░░░▒▓▓▒░░░▒▓▓▓▒
                     ▒▓▓▓▒░░░░▒▓▓▓▒
                        ▒▒▓▓▓▓▒▒


                Welcome to Metro v0.76.5
              Fast - Scalable - Integrated

r - reload the app
d - open developer menu
i - run on iOS
a - run on Android

node:events:491
      throw er; // Unhandled 'error' event
      ^

TypeError: resp.asserted-states is not iterable
    at Object.onSubscribe [as cb] (D:\Sources\Personal\AwesomeProject\node_modules\metro-file-map\src\watchers\WatchmanWatcher.js:174:31)
    at BunserBuf.<anonymous> (D:\Sources\Personal\AwesomeProject\node_modules\fb-watchman\index.js:103:15)
    at BunserBuf.emit (node:events:513:28)
    at BunserBuf.process (D:\Sources\Personal\AwesomeProject\node_modules\bser\index.js:292:10)
    at D:\Sources\Personal\AwesomeProject\node_modules\bser\index.js:247:12
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
Emitted 'error' event on WatchmanWatcher instance at:
    at Client.<anonymous> (D:\Sources\Personal\AwesomeProject\node_modules\metro-file-map\src\watchers\WatchmanWatcher.js:107:12)
    at Client.emit (node:events:513:28)
    at BunserBuf.<anonymous> (D:\Sources\Personal\AwesomeProject\node_modules\fb-watchman\index.js:111:12)
    at BunserBuf.emit (node:events:513:28)
    at D:\Sources\Personal\AwesomeProject\node_modules\bser\index.js:249:12
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)

Node.js v18.16.1

解决方案

  • 升级Watchman到最新版本:该错误多由Watchman版本与Metro不兼容导致,Windows环境安装最新版Watchman后,重启终端再执行npm start。
  • 强制Metro使用Node文件监听替代Watchman:在项目根目录创建metro.config.js,添加以下配置:
module.exports = {
  watchFolders: [__dirname],
  watcher: 'node',
};

保存后重新启动Metro。

  • 清除项目缓存:执行npx react-native start --reset-cache,或删除node_modules、package-lock.json后重新执行npm install,再启动Metro。

内容的提问来源于stack exchange,提问作者Hans Yulian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.17 03:32:45