pnpm create
/ pnpm init
should expose an npm_config_user_agent
environment variable
#4257
Labels
pnpm create
/ pnpm init
should expose an npm_config_user_agent
environment variable
#4257
pnpm version:
6.27.0
Code to reproduce the issue:
I created a
create-soda-test
package to print all the environment variables: https://unpkg.com/create-soda-test@0.0.3/index.jsYou can run
pnpm create soda-test@0.0.3
to see the available environment variables thatpnpm create
exposes.There's no
npm_config_user_agent
.The environment variable is available in
pnpm run
though.Expected behavior:
A
npm_config_user_agent
environment variable is exposed.Actual behavior:
process.env.npm_config_user_agent
is unavailable inpnpm create
orpnpm init
, making it impossible to tell where the user is invoking the package from.Additional information:
node -v
prints: v16.13.1The use case:
In
create-vite
andcreate-vue
, we need to show the user a few package-manager-related instructions after the project is scaffolded. Something like:cd my-project npm install npm run dev
When the user invokes these packages via
yarn create
,pnpm create
orpnpm init
, we want to show commands that match their preferred package manager.So we need a way to tell which package manager they are using.
We are told to use
process.env.npm_config_user_agent
as it's the safest check.But it's only available in
npm init
oryarn create
, not in the corresponding pnpm commands. Therefore, we are unable to print pnpm-specific commands, despite that we are trying to recommend users to choose pnpm.The text was updated successfully, but these errors were encountered: