We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
config
Support for config in package.json. https://docs.npmjs.com/cli/v9/configuring-npm/package-json#config
package.json
When adding in package.json:
{ ... "config": { "foo": "bar" }, ... }
Expected to have env variable: npm_package_config_foo but seems not to have it.
npm_package_config_foo
Here the test code (./src/index.js):
./src/index.js
const { env } = process; const envEntries = Object.entries(env); const npmEnvArray = envEntries.filter(([key]) => key.startsWith('npm')); const npmEnv = Object.fromEntries(npmEnvArray); console.log(npmEnv);
Package.json file
{ "name": "test-project", "module": "src/index.js", "type": "module", "config": { "foo": "bar" }, "scripts": { "start:bun": "bun run ./src/index.js", "start:node": "node ./src/index.js" }, "devDependencies": { "bun-types": "^0.5.0" }, "peerDependencies": { "typescript": "^5.0.0" } }
$ bun run ./src/index.js { "npm_config_local_prefix": "/Users/gtrabanco/MyProjects/test-project/", "npm_package_name": "test-project", "npm_config_user_agent": "bun/0.6.0 npm/? node/v18.15.0 darwin x64", "npm_execpath": "/Users/gtrabanco/.bun/bin/bun", "npm_package_json": "/Users/gtrabanco/MyProjects/test-project/package.json", "npm_node_execpath": "/Users/gtrabanco/.nvm/versions/node/v18.14.2/bin/node" }
> start:node > node ./src/index.js { npm_config_audit: '', npm_config_metrics_registry: 'https://registry.npmjs.org/', npm_config_global_prefix: '/Users/gtrabanco/.nvm/versions/node/v18.14.2', npm_config_noproxy: '', npm_config_local_prefix: '/Users/gtrabanco/MyProjects/test-project', npm_package_config_foo: 'bar', npm_config_globalconfig: '/Users/gtrabanco/.nvm/versions/node/v18.14.2/etc/npmrc', npm_execpath: '/Users/gtrabanco/.nvm/versions/node/v18.14.2/lib/node_modules/npm/bin/npm-cli.js', npm_package_json: '/Users/gtrabanco/MyProjects/test-project/package.json', npm_config_userconfig: '/Users/gtrabanco/.npmrc', npm_config_init_module: '/Users/gtrabanco/.npm-init.js', npm_command: 'run-script', npm_lifecycle_event: 'start:node', npm_package_name: 'test-project', npm_config_node_gyp: '/Users/gtrabanco/.nvm/versions/node/v18.14.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js', npm_config_save_prefix: '', npm_config_cache: '/Users/gtrabanco/.npm', npm_lifecycle_script: 'node ./src/index.js', npm_config_fund: '', npm_config_user_agent: 'npm/9.6.5 node/v18.14.2 darwin x64 workspaces/false', npm_node_execpath: '/Users/gtrabanco/.nvm/versions/node/v18.14.2/bin/node', npm_config_prefix: '/Users/gtrabanco/.nvm/versions/node/v18.14.2' }
...
Using .env files and provide hardcoded default values.
The text was updated successfully, but these errors were encountered:
Would love to see some support for this.
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
What is the problem this feature would solve?
Support for config in
package.json
. https://docs.npmjs.com/cli/v9/configuring-npm/package-json#configWhen adding in
package.json
:Expected to have env variable:
npm_package_config_foo
but seems not to have it.Code
Here the test code (
./src/index.js
):Package.json file
Bun Output
Node Output
What is the feature you are proposing to solve the problem?
...
What alternatives have you considered?
Using .env files and provide hardcoded default values.
The text was updated successfully, but these errors were encountered: