Linux Deepin系统中create-react-app命令无法运行求助
Hey there! I’ve run into this exact snag before—when you install a Node.js package globally but your shell can’t locate the command, it’s almost always a PATH configuration issue. Let’s walk through the steps to get create-react-app up and running:
Step 1: Locate your global package bin directory
First, we need to find where your global Node.js/Yarn packages store their executable files. Run one of these commands depending on how you installed create-react-app:
- If you used npm:
npm bin -g - If you used Yarn:
yarn global bin
This will output a path like /home/your-username/.npm-global/bin or /home/your-username/.config/yarn/global/node_modules/.bin—copy this path, we’ll need it next.
Step 2: Check if the path is in your system PATH
Run this command to view your current PATH settings:
echo $PATH
Look for the bin path you copied in Step 1. If it’s missing from the output, that’s why bash can’t find create-react-app.
Step 3: Add the bin path to your PATH permanently
To make this change stick even after restarting your terminal:
- Open your bash configuration file with a simple text editor (nano is great for beginners):
nano ~/.bashrc - Scroll to the bottom of the file and add this line (replace
/path/to/your/binwith the path you copied earlier):export PATH="$PATH:/path/to/your/bin" - Save the file by pressing
Ctrl+O, then exit nano withCtrl+X. - Make the changes take effect right away:
source ~/.bashrc
Alternative: Use npx instead (no global install required)
If you don’t want to tweak PATH settings, you can run create-react-app directly using npx (which comes bundled with Node.js v6+):
npx create-react-app my-react-app
npx will temporarily download the latest version of create-react-app and run it, so you don’t need a global installation at all.
Verify the fix
Run this command to confirm everything works as expected:
create-react-app --version
If it outputs the version number, you’re all set to start building your React app!
内容的提问来源于stack exchange,提问作者David Essien

