-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set npm_config_user_agent when running scripts #25342
Comments
All of these:
|
This environment variable is used by numerous CLIs to detect which package manager to run to install a package. E.g. Svelte uses it when creating a new project or adding integrations to an existing project https://www.npmjs.com/package/which-pm-runs and https://www.npmjs.com/package/package-manager-detector are two highly used packages, which make use of this |
@benmccann thanks for pointing this out. Would it be okay if we only supported |
That would be enough for to be safe I'd probably print something like:
you can see examples of what other package managers do here: https://github.com/antfu-collective/package-manager-detector/blob/d8655170eae1c786de4eda1854af16480575fbb6/test/user-agent.spec.ts#L9 |
yep it should be in the same style of format as how npm defines it, https://github.com/npm/cli/blob/f75da94f3bed6c0b637044e88098ec354cf302b0/workspaces/config/lib/definitions/definitions.js#L2107-L2126. e.g. with bun i get |
Thanks for replies, @dsherret suggests that this should only be set for subprocesses spawned with |
@bartlomieju i think this should only be set for |
well it should also be set for any kind of script you're running that's not a local one, i.e. |
…sks (#26639) Fixes #25342. Still not sure on the exact user agent to set (should it include `node`?). After this PR, here's the state of running some `create-*` packages (just ones I could think of off the top of my head): | package | prints/runs/suggests deno install | notes | | ---------------- | ------------- | ------ | | `create-next-app` | ❌ | falls back to npm, needs a PR ([code](https://github.com/vercel/next.js/blob/c32e2802097c03fd9f95b1dae228d6e0257569c0/packages/create-next-app/helpers/get-pkg-manager.ts#L3)) | `sv create` | ❌ | uses `package-manager-detector`, needs a PR ([code](https://github.com/antfu-collective/package-manager-detector/tree/main)) | `create-qwik` | ✅ | runs `deno install` but suggests `deno start` which doesn't work (should be `deno task start` or `deno run start`) | `create-astro` | ✅ | runs `deno install` but suggests `npm run dev` later in output, probably needs a PR | `nuxi init` | ❌ | deno not an option in dialog, needs a PR ([code](https://github.com/nuxt/cli/blob/f04e2e894446f597da9d971b7eb03191d5a0da7e/src/commands/init.ts#L96-L102)) | `create-react-app` | ❌ | uses npm | `ng new` (`@angular/cli`) | ❌ | uses npm | `create-vite` | ✅ | suggests working deno commands 🎉 | `create-solid` | ❌ | suggests npm commands, needs PR It's possible that fixing `package-manager-detector` or other packages might make some of these just work, but haven't looked too carefully at each
this is an env var that many scripts use to detect the package manager that ran the script. all major package managers including bun set this env var and it would be great if deno did too.
The text was updated successfully, but these errors were encountered: