Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚙️Migrate from yarn to pnpm #44

Closed
4 tasks done
CalvinWilkinson opened this issue Dec 3, 2023 · 0 comments · Fixed by #59
Closed
4 tasks done

⚙️Migrate from yarn to pnpm #44

CalvinWilkinson opened this issue Dec 3, 2023 · 0 comments · Fixed by #59
Assignees
Labels
⚙️config Configuration related work

Comments

@CalvinWilkinson
Copy link
Member

CalvinWilkinson commented Dec 3, 2023

Complete The Item Below

  • I have updated the title without removing the ⚙️ emoji.

Description

Migrate the current package management system of yarn to pnpm.

Additional Info:

Follow these steps to migrate:

Sure, here are the steps to migrate from Yarn to PNPM for a Docusaurus website:

  1. Install PNPM: You can install PNPM globally using npm with the command npm install -g pnpm¹.
  2. Delete node_modules: You can use npx npkill to delete the node_modules directory¹.
    1. Add to package.json: Add the following to your package.json file under "scripts": { "preinstall": "npx only-allow pnpm" }.

    Note
    This will prevent other developers from accidentally installing dependencies with anything other than PNPM¹.

  3. Run pnpm import: This command will create a pnpm-lock.yaml file based on yarn.lock¹.
  4. Remove yarn.lock: Remove the yarn.lock file from your project¹.
  5. Install dependencies: Run pnpm i to install the dependencies¹.
  6. Replace yarn with pnpm: Replace all instances of yarn with pnpm in all package.json and other files. For example, change yarn test to pnpm test¹.

Please note that PNPM doesn't use dependency hoisting by default. If you have a package A that imports a package B but doesn’t explicitly specify B in the dependencies or devDependencies, then the execution will fail.

Here is a code block that shows the changes in package.json:

{
  "scripts": {
    "preinstall": "npx only-allow pnpm",
    ...
  },
  ...
}

Update NPM Scripts:

Also, update the npm scripts in the package.json to use pnpm instead of yarn.

  "scripts": {
    "docusaurus": "docusaurus",
-    "start": "docusaurus start",
+    "start": "pnpm i && docusaurus start",
-   "build": "docusaurus build",
+    "build": "pnpm i && docusaurus build",
    "swizzle": "docusaurus swizzle",
    "deploy": "docusaurus deploy",
    "clear": "docusaurus clear",
    "serve": "docusaurus serve",
    "write-translations": "docusaurus write-translations",
    "write-heading-ids": "docusaurus write-heading-ids",
    "typecheck": "tsc",
    "clean": "@powershell Remove-Item .\\node_modules -Force -Recurse",
    "preinstall": "npx only-allow pnpm"
  },

Acceptance Criteria

Acceptance Criteria

Preview Give feedback

ToDo Items

  • Issue linked to the correct project (if applicable).
  • Draft pull request created and linked to this issue (only required with code changes).

Code of Conduct

  • I agree to follow this project's Code of Conduct.
@CalvinWilkinson CalvinWilkinson added the ⚙️config Configuration related work label Dec 3, 2023
@CalvinWilkinson CalvinWilkinson self-assigned this Dec 3, 2023
@github-project-automation github-project-automation bot moved this to ⚪Not Set in KD-Team Dec 3, 2023
@CalvinWilkinson CalvinWilkinson moved this from ⚪Not Set to 🏗️In Development in KD-Team Jan 2, 2024
CalvinWilkinson added a commit that referenced this issue Jan 2, 2024
CalvinWilkinson added a commit that referenced this issue Jan 2, 2024
* Start work for issue #44

* config: replace yarn with pnpm

* ci: update workflows to use pnpm instead of yarn

* config: improve npm scripts

* ide: add words to dictionary
@github-project-automation github-project-automation bot moved this from 🏗️In Development to ✅Done in KD-Team Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚙️config Configuration related work
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant