执行npx create-react-app my-app命令失败,报错“npx未被识别”求助
原因分析
出现npx : The term 'npx' is not recognized...错误,主要有以下几种可能:
- Node.js未安装:npx是Node.js生态自带的工具,随Node.js一同分发,系统中未安装Node.js的话,终端无法识别npx命令。
- Node.js可执行目录未加入系统环境变量(PATH):即便安装了Node.js,如果npm/npx所在的
bin目录(Windows下通常为C:\Users\<你的用户名>\AppData\Roaming\npm,Mac/Linux下为/usr/local/bin或用户目录下的.npm-global/bin)未被添加到系统PATH中,终端找不到npx的执行文件。 - 终端会话未刷新:刚完成Node.js安装后,当前打开的终端可能还未加载新的环境变量,需要重启终端或手动刷新(Windows执行
refreshenv,Mac/Linux执行source ~/.bashrc或source ~/.zshrc)。 - 拼写错误:虽然本次错误中的命令拼写无误,但如果输入时误写为
npm或其他变体,也会触发类似错误,此案例可排除该情况。
npx : The term 'npx' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and
try again. At line:1 char:1
- npx create-react-app my-app
+ CategoryInfo : ObjectNotFound: (npx:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
内容的提问来源于stack exchange,提问作者Ashutosh Kumar Singh
相关产品推荐
相关产品推荐

