Error while trying to build the NX dev container

38 views Asked by At

I'm trying to contribute with NX project, but I;m getting an error on the dev container while trying to install the dependencies.

VSCode dev container extension build the container, and runned the sudo apt-get update && sudo apt-get -y upgrade commands sucessifully, but when it's try to run the pnpm install, it's throwing an error

 ERR_PNPM_ENOENT  ENOENT: no such file or directory, copyfile '/workspaces/nx/.pnpm-store/v3/files/4e/e1c88f8c3f4e4cd34cb6c00339bf9d6d036ff4ade3af49e871cc8966b84c729d8b75492acc6413c9a664ac00a57958223ac13c4229da8c62ebe6a53e4f783f' -> '/workspaces/nx/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/ts-node_tmp_767/dist/cjs-resolve-hooks.d.ts'

I've tried to rebuild the container some times, and run pnpm install directly, but the first throws the same error, while the second throws Error: Cannot find module '/home/node/.vscode-server/data/User/workspaceStorage/d79600a30618d2a2c36ab67ceb766aae/ms-vscode.js-debug/bootloader.js'

It's my first time using dev containers, so I have no clue how to handle the error.

1

There are 1 answers

4
Dainis On

A content-addressable store is utilized by pnpm for managing dependencies. Dev Containers often mount project directories from the host machine's filesystem (e.g., /workspaces/nx), relying on the host's directory structure being available.

Thus these dependencies may end up in the mounted directory, which can be confirmed with pnpm store path command. To avoid compatibility issues or file access permissions errors, pnpm can be configured to use a local directory within the container itself for its store:

pnpm config set store-dir ~/.local/share/pnpm/store

Note: node_modules will need to be deleted and the dependencies reinstalled (pnpm install).

Additional information:

Does pnpm work across multiple drives or filesystems?

The package store should be on the same drive and filesystem as installations, otherwise packages will be copied, not linked. This is due to a limitation in how hard linking works, in that a file on one filesystem cannot address a location in another.