npx执行后批处理脚本终止?React项目初始化脚本问题求助
解决React初始化批处理脚本中断问题
在Windows批处理环境中,直接执行npx或npm这类命令时,它们会接管当前的批处理进程,导致脚本在执行完这些命令后直接终止,后续步骤无法运行。要让脚本完整执行所有步骤,只需在这类外部命令前添加call指令,让命令在子进程中执行,执行完成后回到原批处理继续后续操作。
修改后的完整脚本如下:
@echo off set /p userInput=Enter the folder name for your new React app: mkdir %userInput% cd %userInput% call npx create-react-app . --template cra-template-pwa call npm install -D tailwindcss call npx tailwindcss init echo. echo Finished setting up React environment pause
这样修改后,脚本会依次完成所有步骤,直到最后暂停等待用户操作。
内容的提问来源于stack exchange,提问作者Cardinal System
相关产品推荐
相关产品推荐

