From cf343ee5530cd21504c41bca80808e4332441e11 Mon Sep 17 00:00:00 2001 From: yzh990918 <251205668@qq.com> Date: Wed, 2 Nov 2022 16:05:31 +0800 Subject: [PATCH] fix: fix pnpm install hoist bug --- packages/init/src/npmrc.ts | 3 +++ packages/init/src/template.ts | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 packages/init/src/npmrc.ts diff --git a/packages/init/src/npmrc.ts b/packages/init/src/npmrc.ts new file mode 100644 index 0000000..f9590d7 --- /dev/null +++ b/packages/init/src/npmrc.ts @@ -0,0 +1,3 @@ +export const npmrcContent = `shamefully-hoist=true +strict-peer-dependencies=false +` diff --git a/packages/init/src/template.ts b/packages/init/src/template.ts index 5728b35..4687e22 100644 --- a/packages/init/src/template.ts +++ b/packages/init/src/template.ts @@ -8,6 +8,7 @@ import ejs from 'ejs' import { execaCommand } from 'execa' import ora from 'ora' import { fileContent } from './gitignore' +import { npmrcContent } from './npmrc' import type { TemplateListItem } from '@vbs/magic-cli-templates' import type { ProjectInfo } from './type' @@ -104,7 +105,7 @@ export async function renderTemplate(template: TemplateListItem, projectInfo: Pa try { info('🔫 正在执行依赖安装命令...') - fse.writeFileSync(path.resolve(targetPath, '.npmrc'), 'strict-peer-dependencies = false') + fse.writeFileSync(path.resolve(targetPath, '.npmrc'), npmrcContent) fse.writeFileSync(path.resolve(targetPath, '.gitignore'), fileContent) await execaCommand(installCommand, { stdio: 'inherit', encoding: 'utf-8', cwd: targetPath }) } catch (error: any) {