deno
deno copied to clipboard
NPM_CONFIG_REGISTRY environment variable is not respected
Version:
deno 2.0.0-rc.4 (release candidate, release, x86_64-pc-windows-msvc)
v8 12.9.202.13-rusty
typescript 5.6.2
> Deno.env.get("NPM_CONFIG_REGISTRY")
"https://registry.npmmirror.com/"
>
deno install npm:prisma-kysely
Add npm:[email protected]
error: Error getting response at https://registry.npmjs.org/prisma-kysely for package "prisma-kysely": error sending request for url (https://registry.npmjs.org/prisma-kysely): client error (Connect): 远程主机强迫关闭了一个现有的连接。 (os error 10054)
That's odd. We have tests that check that this works and during testing we test all the npm installation stuff with our own mock registry.
https://github.com/denoland/deno/blob/main/tests/specs/node_compat_tests/node_test_module/test.jsonc#L6
Can you post the output of running the following command on your machine?
NPM_CONFIG_REGISTRY="https://registry.npmmirror.com/" DENO_LOG=debug deno install npm:prisma-kysely
DEBUG RS - deno_config::deno_json:781 - Config file found at 'H:\hlbcg\repo\hello-prisma-2\deno.json'
DEBUG RS - deno_config::workspace::discovery:263 - package.json file found at 'H:\hlbcg\repo\hello-prisma-2\package.json'
DEBUG RS - deno::args:915 - Finished config loading.
DEBUG RS - deno::file_fetcher:641 - FileFetcher::fetch_no_follow_with_options - specifier: https://registry.npmmirror.com/prisma-kysely
DEBUG RS - deno::file_fetcher:375 - FileFetcher::fetch_remote_no_follow - specifier: https://registry.npmmirror.com/prisma-kysely
DEBUG RS - hyper_util::client::legacy::connect::dns:122 - resolving host="registry.npmmirror.com"
DEBUG RS - hyper_util::client::legacy::connect::http:643 - connecting to 119.147.148.206:443
DEBUG RS - hyper_util::client::legacy::connect::http:646 - connected to 119.147.148.206:443
DEBUG RS - h2::client:1281 - binding client connection
DEBUG RS - h2::client:1286 - client connection bound
DEBUG RS - h2::codec::framed_write:213 - send frame=Settings { flags: (0x0), enable_push: 0, initial_window_size: 2097152, max_frame_size: 16384, max_header_list_size: 16384 }
DEBUG RS - h2::proto::connection:138 - Connection; peer=Client
DEBUG RS - hyper_util::client::legacy::pool:396 - pooling idle connection for ("https", registry.npmmirror.com)
DEBUG RS - h2::codec::framed_write:213 - send frame=WindowUpdate { stream_id: StreamId(0), size_increment: 5177345 }
DEBUG RS - h2::codec::framed_write:213 - send frame=Headers { stream_id: StreamId(1), flags: (0x5: END_HEADERS | END_STREAM) }
DEBUG RS - h2::codec::framed_read:405 - received frame=Settings { flags: (0x0), max_concurrent_streams: 128, initial_window_size: 65536, max_frame_size: 16777215 }
DEBUG RS - h2::codec::framed_write:213 - send frame=Settings { flags: (0x1: ACK) }
DEBUG RS - h2::codec::framed_read:405 - received frame=WindowUpdate { stream_id: StreamId(0), size_increment: 2147418112 }
DEBUG RS - h2::codec::framed_read:405 - received frame=Settings { flags: (0x1: ACK) }
DEBUG RS - h2::proto::settings:56 - received settings ACK; applying Settings { flags: (0x0), enable_push: 0, initial_window_size: 2097152, max_frame_size: 16384, max_header_list_size: 16384 }
DEBUG RS - h2::codec::framed_read:405 - received frame=Headers { stream_id: StreamId(1), flags: (0x5: END_HEADERS | END_STREAM) }
Add npm:[email protected]
DEBUG RS - deno_config::deno_json:781 - Config file found at 'H:\hlbcg\repo\hello-prisma-2\deno.json'
DEBUG RS - deno_config::workspace::discovery:263 - package.json file found at 'H:\hlbcg\repo\hello-prisma-2\package.json'
DEBUG RS - deno::args:915 - Finished config loading.
DEBUG RS - deno::npm::managed::resolution:282 - Running npm resolution.
DEBUG RS - hyper_util::client::legacy::connect::dns:122 - resolving host="registry.npmjs.org"
DEBUG RS - hyper_util::client::legacy::connect::http:643 - connecting to 104.16.25.34:443
DEBUG RS - deno_npm::resolution::graph:927 - <package-req> - Resolved prisma-kysely@^1.8.0 to [email protected]
DEBUG RS - hyper_util::client::legacy::connect::http:646 - connected to 104.16.25.34:443
DEBUG RS - h2::client:1281 - binding client connection
DEBUG RS - h2::client:1286 - client connection bound
DEBUG RS - h2::codec::framed_write:213 - send frame=Settings { flags: (0x0), enable_push: 0, initial_window_size: 2097152, max_frame_size: 16384, max_header_list_size: 16384 }
DEBUG RS - h2::proto::connection:138 - Connection; peer=Client
DEBUG RS - hyper_util::client::legacy::pool:396 - pooling idle connection for ("https", registry.npmjs.org)
DEBUG RS - h2::codec::framed_read:405 - received frame=Settings { flags: (0x0), max_concurrent_streams: 100, initial_window_size: 65536, max_frame_size: 16777215 }
DEBUG RS - h2::codec::framed_write:213 - send frame=Settings { flags: (0x1: ACK) }
DEBUG RS - h2::codec::framed_read:405 - received frame=WindowUpdate { stream_id: StreamId(0), size_increment: 2147418112 }
DEBUG RS - h2::codec::framed_write:213 - send frame=WindowUpdate { stream_id: StreamId(0), size_increment: 5177345 }
DEBUG RS - h2::codec::framed_write:213 - send frame=Headers { stream_id: StreamId(1), flags: (0x5: END_HEADERS | END_STREAM) }
DEBUG RS - h2::codec::framed_read:405 - received frame=Settings { flags: (0x1: ACK) }
DEBUG RS - h2::proto::settings:56 - received settings ACK; applying Settings { flags: (0x0), enable_push: 0, initial_window_size: 2097152, max_frame_size: 16384, max_header_list_size: 16384 }
DEBUG RS - h2::codec::framed_read:405 - received frame=Headers { stream_id: StreamId(1), flags: (0x4: END_HEADERS) }
DEBUG RS - h2::codec::framed_read:405 - received frame=Data { stream_id: StreamId(1) }
DEBUG RS - h2::codec::framed_read:405 - received frame=Data { stream_id: StreamId(1) }
DEBUG RS - h2::codec::framed_read:405 - received frame=Data { stream_id: StreamId(1) }
DEBUG RS - h2::codec::framed_read:405 - received frame=Data { stream_id: StreamId(1) }
DEBUG RS - h2::codec::framed_read:405 - received frame=Data { stream_id: StreamId(1) }
DEBUG RS - h2::codec::framed_read:405 - received frame=Data { stream_id: StreamId(1) }
DEBUG RS - h2::codec::framed_read:405 - received frame=Data { stream_id: StreamId(1), flags: (0x1: END_STREAM) }
DEBUG RS - deno_npm::resolution::graph:927 - <package-req> - Resolved @mrleebo/prisma-ast@* to @mrleebo/[email protected]
DEBUG RS - deno_npm::resolution::graph:927 - [email protected] - Resolved @mrleebo/prisma-ast@^0.7.0 to @mrleebo/[email protected]
DEBUG RS - hyper_util::client::legacy::pool:270 - reuse idle connection for ("https", registry.npmjs.org)
DEBUG RS - h2::codec::framed_write:213 - send frame=Headers { stream_id: StreamId(3), flags: (0x5: END_HEADERS | END_STREAM) }
DEBUG RS - hyper_util::client::legacy::pool:270 - reuse idle connection for ("https", registry.npmjs.org)
DEBUG RS - hyper_util::client::legacy::pool:270 - reuse idle connection for ("https", registry.npmjs.org)
DEBUG RS - h2::codec::framed_write:213 - send frame=Headers { stream_id: StreamId(5), flags: (0x5: END_HEADERS | END_STREAM) }
DEBUG RS - h2::codec::framed_write:213 - send frame=Headers { stream_id: StreamId(7), flags: (0x5: END_HEADERS | END_STREAM) }
DEBUG RS - h2::proto::connection:461 - Connection::poll; IO error error=ConnectionReset
DEBUG RS - hyper_util::client::legacy::client:569 - client connection error: connection error
DEBUG RS - h2::codec::framed_write:213 - send frame=GoAway { error_code: NO_ERROR, last_stream_id: StreamId(0) }
DEBUG RS - h2::proto::connection:428 - Connection::poll; connection error error=GoAway(b"", NO_ERROR, Library)
error: Error getting response at https://registry.npmjs.org/@prisma/generator-helper for package "@prisma/generator-helper": error sending request from 172.16.111.251:60802 for https://registry.npmjs.org/@prisma/generator-helper (104.16.25.34:443): client error (SendRequest): connection error: connection reset
That is very odd - I can not reproduce it on Linux with NPM_CONFIG_REGISTRY="https://registry.npmmirror.com/" DENO_LOG=debug deno info -Ldebug npm:prisma-kysely. @dsherret do you have any ideas? Could this somehow be windows specific?
@leonco do you have an .npmrc file in your current directory or home directory? It should log that out in the debug log if so.
Edit: Oh, I guess that's the full output and it doesn't say that
yes, I have a .npmrc file in home directory
registry=https://registry.npmjs.org/
There are multiple places to configure the npm registry. Can you tell me about your processing logic?
@dsherret
I think the env var has the lowest precedence. It seems some of the code incorrectly uses the env var when it should be using the npmrc though.
FYI you can upgrade to canary version to get this fix immediately (deno upgrade canary) or wait until stable Deno v2.0.3 that should be released tonight.
Hello @bartlomieju @dsherret , sorry to bother you. In my limited experience, environment variables seem to have higher priority than configuration files? Is this a bug? I tried it in npm, and NPM_CONFIG_REGISTRY does indeed have higher priority than .npmrc.
In modern software applications, there is a widely accepted standard for the order of precedence in which configuration settings are applied. This hierarchy ensures flexibility and predictable behavior across different environments. The established priority, from highest to lowest, is: Command-line arguments, environment variables, configuration files, and finally, in-app default values. This allows developers and operators to make temporary overrides for testing (via command line), specify environment-specific settings without changing code (via environment variables), and maintain stable, version-controlled defaults in configuration files.[2][11]
This principle is not just a theoretical best practice but is implemented consistently across major frameworks, tools, and industry standards.
Key evidence and documentation:
* **The Twelve-Factor App:** A foundational methodology for building modern applications that advocates for storing configuration in the environment, separate from code.[12]
* **Spring Boot:** The official documentation explicitly details a precise order of property sources, with command-line arguments having the highest precedence.[13]
* **AWS Command Line Interface (CLI):** Amazon's documentation confirms that command-line options override environment variables, which in turn override settings in configuration files.[14][15]
* **Terraform:** This popular Infrastructure as Code tool follows a strict variable precedence order where command-line flags (`-var` and `-var-file`) override environment variables, which override variable files (`.tfvars`) and in-code defaults.[16][17]
* **Ansible:** The configuration priority for Ansible places command-line options and extra variables at the highest level of precedence, overriding all other settings.[18][19]
* **Go (Viper Library):** A popular configuration library for Go that explicitly defines its precedence order, with command-line flags and environment variables overriding configuration files and defaults.[20][21]
[1](https://help.splunk.com/en/data-management/splunk-enterprise-admin-manual/9.4/administer-splunk-enterprise-with-configuration-files/configuration-file-precedence)
[2](https://stackoverflow.com/questions/56019326/configuration-priority-best-practise)
[3](https://www.cloudeagle.ai/blogs/configuration-management-best-practices)
[4](https://larion.com/practical-guide-to-software-configuration-management/)
[5](https://fibery.io/blog/product-management/software-prioritization-matrix/)
[6](https://learn.microsoft.com/en-us/intune/configmgr/core/plan-design/hierarchy/fundamental-concepts-for-content-management)
[7](https://seata.apache.org/blog/beginner-guide-to-how-seata-loads-configurations%E2%80%93part1/)
[8](https://railroads.dot.gov/sites/fra.dot.gov/files/fra_net/18419/software_config_06.pdf)
[9](https://www.sysadmins.lv/blog-en/software-restriction-policies-rule-ordering.aspx)
[10](https://docs.contrastsecurity.com/en/order-of-precedence.html)
[11](https://stackoverflow.com/questions/11077223/what-order-of-reading-configuration-values)
[12](https://[12factor](https://12factor.net/config).net/config)
[13](https://docs.spring.io/spring-boot/reference/features/external-config.html)
[14](https://docs.aws.amazon.com/cli/v1/userguide/cli-chap-configure.html)
[15](https://docs.aws.amazon.com/cli/latest/topic/config-vars.html)
[16](https://wintelguy.com/2025/understanding-terraform-variable-precedence.html)
[17](https://blog.devops.dev/terraform-variables-and-precedence-0fa986e5c2db)
[18](https://dev.to/vishnutejas/understanding-ansible-configuration-priority-1mej)
[19](https://spacelift.io/blog/ansible-variable-precedence)
[20](https://pkg.go.dev/github.com/spf13/viper)
[21](https://github.com/spf13/viper)
Have you tried it with Deno? Does env var have lower precedence than .npmrc? If so, I'd suggest to open a new issue instead of resurrecting an old one.
Have you tried it with Deno? Does env var have lower precedence than
.npmrc? If so, I'd suggest to open a new issue instead of resurrecting an old one.你试过用 Deno 吗?环境变量的优先级是否低于.npmrc文件?如果是这样,我建议你创建一个新的 issue,而不是回复一个旧 issue。
Yes, okay. Here it is: https://github.com/denoland/deno/issues/31392