Non-Interactive pnpm install --no-optional hangs without --config.confirmModulesPurge=false
#6,778 创建于 2023年7月7日
描述
Hello,
I recently encountered an issue with pnpm version 8.6.6 during a Docker build process.
When running the command in a Dockerfile:
pnpm install --no-optional -r --offline --ignore-scripts --frozen-lockfile
the command did not fail but led to an empty node_modules folder.
I found that when running the same command interactively inside the Docker container, a confirmation prompt was shown. After confirming with Y, the command executed as expected.
However, this behavior is problematic in non-interactive environments like Docker builds, where the command cannot receive any user input.
As a workaround, I used the --config.confirmModulesPurge=false option to automatically confirm the prompt, as shown below:
pnpm install --no-optional -r --offline --ignore-scripts --frozen-lockfile --config.confirmModulesPurge=false
This successfully bypassed the confirmation and the node_modules folder was correctly populated.
Although I was able to find a workaround, I believe it would be helpful to improve the handling of this situation, perhaps by making the --no-optional flag non-interactive by default, or providing clear documentation about the need for --config.confirmModulesPurge=false in non-interactive environments.
Thank you for your attention to this issue!