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

Mac下React Native执行npm install失败,求助原因及解决办法

Fixing the 'graceful-fs' Not Found Error in React Native Setup

Hey there! I’ve seen this exact graceful-fs issue pop up a lot with new React Native devs—let’s walk through some concrete fixes to get you up and running:

Step 1: Nuke Corrupted npm Cache

First up, npm’s cache is often the culprit here. Corrupted cache entries can make npm think packages are missing even when they exist. Run this command to wipe it clean:

npm cache clean --force

Step 2: Reset Your Project Dependencies

Your local node_modules folder or lock file might have a broken dependency tree. Let’s start fresh:

  • Delete the entire node_modules folder:
    rm -rf node_modules
    
  • Delete your package-lock.json file (if you’re using npm):
    rm package-lock.json
    

Step 3: Reinstall graceful-fs Directly

Sometimes npm needs a little nudge to grab the correct version of graceful-fs. Install it explicitly first, then reinstall all dependencies:

npm install graceful-fs@latest --save
npm install

Step 4: Check Global npm Packages

Since you installed react-native-cli globally, there might be a broken graceful-fs instance in your global npm space too. Let’s fix that:

  • First, check if global graceful-fs is messed up:
    npm ls -g graceful-fs
    
  • If you see errors, reinstall it globally:
    npm install -g graceful-fs@latest
    

Step 5: Reset Watchman (Just in Case)

You mentioned you installed Watchman—sometimes its internal cache can interfere with npm’s operations. Reset it with:

watchman watch-del-all && watchman shutdown-server

Final Check

After running all these steps, try starting your React Native project again:

npm start

If you still hit issues, double-check that your Node.js version matches React Native’s recommended LTS version (avoid bleeding-edge releases—they can cause compatibility hiccups).

内容的提问来源于stack exchange,提问作者GʀᴜᴍᴘʏCᴀᴛ

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 06:52:37