diff --git a/packages/toolkits/pro/src/lib/init.ts b/packages/toolkits/pro/src/lib/init.ts index c4337a22..bfeb1e89 100644 --- a/packages/toolkits/pro/src/lib/init.ts +++ b/packages/toolkits/pro/src/lib/init.ts @@ -291,19 +291,27 @@ export const installDependencies = (answers: ProjectInfo) => { // egg服务端 安装依赖并启动 if (serverConfirm && serverFramework === ServerFrameworks.EggJs) { log.info('正在安装服务端 npm 依赖,安装过程需要几十秒,请耐心等待...'); - spawn.sync('npm', ['install'], { + const installServiceResult = spawn.sync('npm', ['install'], { cwd: `${name}/${serverFramework}/`, stdio: 'inherit', }); - log.success('服务端 npm 依赖安装成功'); + if(installServiceResult.status === 0) { + log.success('服务端 npm 依赖安装成功'); + }else { + throw new Error(installServiceResult.error); + } } // npm 依赖安装 log.info('正在安装客户端 npm 依赖,安装过程需要几十秒,请耐心等待...'); - spawn.sync('npm', ['install'], { + const installClientResult = spawn.sync('npm', ['install'], { cwd: serverConfirm ? `${name}/web` : `${name}/`, stdio: 'inherit', }); - log.success('客户端 npm 依赖安装成功'); + if(installClientResult.status === 0) { + log.success('客户端 npm 依赖安装成功'); + }else { + throw new Error(installClientResult.error); + } /* prettier-ignore-start */ console.log(