使用create-react-app时遭遇ENOENT错误求助(Windows10环境)
create-react-app on Windows 10 Hey there, sorry to hear you're stuck with this ENOENT error while trying to get started with React—totally frustrating when you're just trying to follow a tutorial! Let's go through some additional troubleshooting steps that might help since you've already knocked out the common fixes:
Clean up npm cache and global packages
First, clear out any cached files that might be corrupted:npm cache clean --forceThen, make sure you don't have a global installation of
create-react-appconflicting with npx's latest version:npm uninstall -g create-react-appNow try creating your project again with the explicit latest version flag:
npx create-react-app@latest my-react-appVerify directory permissions and paths
Even if you tried the user folder, double-check that your user account has full read/write access to the folder you're working in:- Right-click your target folder → Properties → Security
- Select your user account and ensure "Full Control" is enabled
Also, avoid paths with special characters (spaces, non-English letters) — stick to simple paths likeC:\Users\YourName\my-app.
Check Node.js environment variables
- Open System Properties → Advanced → Environment Variables
- In both User Variables and System Variables, confirm the
PATHincludes your Node.js installation folder (usuallyC:\Program Files\nodejs\) - Remove any suspicious paths that might reference old Node.js instances (like leftover Adobe-related entries)
Restart your terminal after making changes to apply the updates.
Try a fresh PowerShell session with script permissions
Open PowerShell as Administrator and run this first to allow script execution:Set-ExecutionPolicy RemoteSignedPress
Yto confirm, then try running thenpx create-react-appcommand again in this session.Temporarily disable security tools
Sometimes Windows Defender or third-party antivirus software can block npm from creating files, triggering ENOENT errors. Disable these tools temporarily, attempt to create your project, then re-enable them once it's successful.Manually build the project structure (last resort)
If all else fails, you can replicate thecreate-react-appsetup manually:- Create a new folder, navigate into it, and initialize a package.json:
npm init -y - Install required dependencies:
npm install react react-dom npm install --save-dev react-scripts - Update the
scriptssection in yourpackage.jsonto match:"scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" } - Create
publicandsrcfolders:- Add an
index.htmlinpublic(use the basic template from React's official docs) - Add
App.jsandindex.jsinsrcwith the default React starter code
- Add an
- Create a new folder, navigate into it, and initialize a package.json:
内容的提问来源于stack exchange,提问作者Fisheye Wout

