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

React Native开发环境搭建报错:执行npm start出现UnhandledPromiseRejectionWarning

解决Expo启动时Cannot find module 'fs/promises'错误

解决方案步骤

  • 检查当前Node.js版本:打开终端执行
    node -v
    
    如果输出版本低于14.0.0,说明版本过低,需要升级。
  • 升级Node.js(推荐用nvm管理版本,避免权限问题):
    • 安装nvm后,执行以下命令安装最新长期支持版(LTS):
      nvm install --lts
      
    • 切换到刚安装的LTS版本:
      nvm use --lts
      
    • 若未使用nvm,可直接下载Node.js官网的LTS版本安装包,覆盖现有版本。
  • 验证版本:再次执行node -v,确认版本≥14.0.0
  • 重新启动项目:
    # Windows系统
    rd /s /q node_modules && del package-lock.json
    # macOS/Linux系统
    rm -rf node_modules package-lock.json
    
    npm install
    npm run android
    

问题原因

fs/promises是Node.js 14.0.0及以上版本才原生支持的内置模块,你当前使用的Node.js版本不支持该模块,导致Expo CLI启动时无法加载依赖文件,进而抛出错误。

错误日志

C:\Users\DELL\Desktop\project> npm run android

> project@1.0.0 android C:\Users\DELL\Desktop\project
> expo start --android

(node:3460) UnhandledPromiseRejectionWarning: Error: Cannot find module 'fs/promises'
Require stack:
- C:\Users\DELL\Desktop\project\node_modules\@expo\cli\build\src\start\doctor\typescript\TypeScriptProjectPrerequisite.js
- C:\Users\DELL\Desktop\project\node_modules\@expo\cli\build\src\start\startAsync.js
- C:\Users\DELL\Desktop\project\node_modules\@expo\cli\build\src\start\index.js
- C:\Users\DELL\Desktop\project\node_modules\@expo\cli\build\bin\cli
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:962:15)
    at Function.Module._load (internal/modules/cjs/loader.js:838:27)
    at Module.require (internal/modules/cjs/loader.js:1022:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (C:\Users\DELL\Desktop\project\node_modules\@expo\cli\build\src\start\doctor\typescript\TypeScriptProjectPrerequisite.js:5:40)
    at Module._compile (internal/modules/cjs/loader.js:1118:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
    at Module.load (internal/modules/cjs/loader.js:982:32)
    at Function.Module._load (internal/modules/cjs/loader.js:875:14)
    at Module.require (internal/modules/cjs/loader.js:1022:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (C:\Users\DELL\Desktop\project\node_modules\@expo\cli\build\src\start\startAsync.js:15:38)
    at Module._compile (internal/modules/cjs/loader.js:1118:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
    at Module.load (internal/modules/cjs/loader.js:982:32)
    at Function.Module._load (internal/modules/cjs/loader.js:875:14)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:3460) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3460) [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.
PS C:\Users\DELL\Desktop\project>

内容的提问来源于stack exchange,提问作者Surya Keshub Misra

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.11 10:00:24