Skip to content

Instantly share code, notes, and snippets.

@mmyoji
Last active July 25, 2024 15:55
Show Gist options
  • Save mmyoji/ea01398a1cbeded5bf1a701711593759 to your computer and use it in GitHub Desktop.
Save mmyoji/ea01398a1cbeded5bf1a701711593759 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

@ekmas
Copy link

ekmas commented Mar 26, 2024

ty

@Sama-004
Copy link

W

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