全局安装vue-cli与create-react-app后执行命令提示bash: command not found
Hey there! I totally get how frustrating it is when you’ve installed a tool globally but can’t run its commands—let’s fix this together. The root issue here is that your Windows system’s environment variables don’t include the folder where npm stores global CLI tools, so your bash shell can’t locate vue or create-react-app.
Let’s walk through the fix step by step:
First, double-check the global npm folder
You’ve already confirmed the path isC:\Users\userlocal\AppData\Roaming\npm—head there in File Explorer and make sure you seevue.cmdandcreate-react-app.cmdfiles. These are the Windows-executable versions of the CLI commands, and they need to live in a path your shell can access.Add the npm global path to your system’s
Pathvariable- Right-click "Computer" (or "This PC") and select Properties
- Click Advanced system settings on the left sidebar
- In the pop-up window, go to the Advanced tab and click Environment Variables
- Under System variables, find the
Pathvariable, select it, and click Edit - Add
;C:\Users\userlocal\AppData\Roaming\npmto the end of the existing value (don’t forget the leading semicolon—it separates this path from the previous ones) - Click OK on all open windows to save your changes
Restart your bash terminal
Environment variable changes don’t take effect in already-open shells. Close your Git Bash (or whatever bash terminal you’re using) completely, then open it again.
Now try running vue init webpack my-project or create-react-app project-name—they should work as expected!
A quick side note: Your Node.js and npm versions are a bit outdated, but that’s not the cause of this specific issue. If you run into other weird problems later, updating to more recent LTS versions might help, but let’s get this command issue sorted first.
内容的提问来源于stack exchange,提问作者stonix26

