Skip to content

Instantly share code, notes, and snippets.

@manuelzi
Forked from mmyoji/migrate-npm-to-pnpm.md
Created March 15, 2024 00:21
Show Gist options
  • Save manuelzi/e65bc202453eac10908ba926d5b85864 to your computer and use it in GitHub Desktop.
Save manuelzi/e65bc202453eac10908ba926d5b85864 to your computer and use it in GitHub Desktop.
Migrate npm to pnpm

Install pnpm

https://pnpm.io/installation#using-corepack

$ corepack enable
$ corepack prepare pnpm@latest --activate
$ pnpm --version

package-lock.json to pnpm-lock.yaml

https://pnpm.io/cli/import

  1. Remove node_modules
  2. [Optional] Create pnpm-workspace.yaml if you use workspaces
  3. Run pnpm import
  4. Remove package-lock.json
  5. Run pnpm install
  6. Replace all npm run xxx commands to pnpm run xxx

"engine" on package.json

https://pnpm.io/package_json#engines

If you use the field, you should change it.

CI

npm ci alternative

$ CI=1 pnpm install
$ pnpm install --frozen-lockfile

GitHub Actions

https://pnpm.io/continuous-integration#github-actions

GitLab CI

https://pnpm.io/continuous-integration#gitlab-ci

Others

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment