When I tried to use pnpm with devcontainer, a .pnpm-store
was created in the project root.
It should normally be created in an appropriate path under the home directory.
This directory contains the npm package entities. My understanding is that this is a characteristic of pnpm and it is not in line with pnpm's philosophy to create it in the project root.
Explicitly specify store-dir
in pnpm.
pnpm config set -g store-dir "${HOME}/.local/share/pnpm/store"
Set postCreateCommand
in devcontainer.json
to run this after devcontainer creation.
// .devcontainer/devcontainer.json
{
// ...
"postCreateCommand": ".devcontainer/postCreate.sh",
// ...
}
Contents of .devcontainer/postCreate.sh
.
# .devcontainer/postCreate.sh
#! /usr/bin/env bash
pnpm config set -g store-dir "${HOME}/.local/share/pnpm/store"
pnpm install