Last Updated: 2023-01-03
We successfully migrated all of our applications and web apps from yarn to pnpm without any issues. However, when it was time to migrate our continuous integration (CI) system to pnpm, we faced a challenge. Previously, we were able to install yarn easily by using the node image on circleci.
Upon attempting to integrate pnpm ci using the provided documentation, we faced an issue where we received an error message indicating that we were denied write access.
ERROR No write access to the found global executable directories
The found directories:
/usr/local/bin
Using the original code from https://pnpm.io/continuous-integration#circleci
- restore_cache:
name: Restore pnpm Package Cache
keys:
- pnpm-packages-{{ checksum "pnpm-lock.yaml" }}
- run:
name: Install pnpm package manager
command: |
curl -L https://pnpm.js.org/pnpm.js | node - add --global pnpm@7
- run:
name: Install Dependencies
command: |
pnpm install
- save_cache:
name: Save pnpm Package Cache
key: pnpm-packages-{{ checksum "pnpm-lock.yaml" }}
paths:
- node_modules
We started searching the internet for a solution to the problem we encountered. After some trial and error, we found a solution that involved using the “–prefix=$HOME/.local” option during installation. This option specifies the directory where the package will be installed and can help resolve issues related to write access. By specifying a location in the user’s home directory, we were able to successfully install the package without encountering any further errors.
- restore_cache:
name: Restore pnpm Package Cache
keys:
- pnpm-packages-{{ checksum "pnpm-lock.yaml" }}
- run:
name: Install pnpm package manager
command: |
npm install --prefix=$HOME/.local pnpm@7 -g
- run:
name: Install Dependencies
command: |
pnpm install
- save_cache:
name: Save pnpm Package Cache
key: pnpm-packages-{{ checksum "pnpm-lock.yaml" }}
paths:
- node_modules
We realized that we needed to use a cimg image that had node installed in order to proceed. Once we made this change, everything worked smoothly, and we immediately noticed a significant increase in speed compared to when we were using yarn