Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
feat(nuxi): auto-generate .npmrc and setting for pnpm (#7407)
Browse files Browse the repository at this point in the history
Co-authored-by: Pooya Parsa <pooya@pi0.io>
  • Loading branch information
kecrily and pi0 committed Nov 11, 2022
1 parent cd2e004 commit 2f53495
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion docs/content/1.getting-started/2.installation.md
Expand Up @@ -74,11 +74,15 @@ npm install
```

```bash [pnpm]
pnpm install --shamefully-hoist
pnpm install
```

::

::alert
**Note:** If using **pnpm**, make sure to have `.npmrc` with `shamefully-hoist=true` inside it before `pnpm install`.
::

## Development Server

Now you'll be able to start your Nuxt app in development mode:
Expand Down
10 changes: 9 additions & 1 deletion packages/nuxi/src/commands/init.ts
@@ -1,3 +1,4 @@
import { writeFile } from 'node:fs/promises'
import { downloadTemplate, startShell } from 'giget'
import { relative } from 'pathe'
import consola from 'consola'
Expand Down Expand Up @@ -27,9 +28,16 @@ export default defineNuxtCommand({

// Show next steps
const relativeDist = rpath(t.dir)

// Write .nuxtrc with `shamefully-hoist=true` for pnpm
const usingPnpm = (process.env.npm_config_user_agent || '').includes('pnpm')
if (usingPnpm) {
await writeFile(`${relativeDist}/.npmrc`, 'shamefully-hoist=true')
}

const nextSteps = [
!args.shell && relativeDist.length > 1 && `\`cd ${relativeDist}\``,
'Install dependencies with `npm install` or `yarn install` or `pnpm install --shamefully-hoist`',
'Install dependencies with `npm install` or `yarn install` or `pnpm install`',
'Start development server with `npm run dev` or `yarn dev` or `pnpm run dev`'
].filter(Boolean)

Expand Down

0 comments on commit 2f53495

Please sign in to comment.