xil*_*il3 6 configuration node.js npm node-gyp
运行它的服务器在公司防火墙后面,只能访问这个特定的私有注册表,它也充当公共 npm 注册表的代理(对于我们没有的包)。
NPM 本身运行良好;但是当使用 node-gyp 模块时,它会尝试执行 GET 到 nodejs.org - gyp http GET https://nodejs.org/download/release/v9.11.2/node-v9.11.2-headers.tar.gz。那失败了,因为系统无权访问它。问题是为什么 node-gyp 不使用 npm 配置中定义的注册表?或者我是否必须为标头设置单独的配置以使用单独的源?
这是我的 npm 配置设置:
; cli configs
metrics-registry = "https://corporate/registry/"
scope = ""
user-agent = "npm/5.6.0 node/v9.11.2 linux x64"
; userconfig /home/user123/.npmrc
always-auth = true
cafile = "/home/user123/pub-cert.crt"
registry = "https://corporate/registry/"
sass_binary_path = "/root/linux-x64-59_binding.node"
strict-ssl = false
Run Code Online (Sandbox Code Playgroud)
阅读完 node-gyp文档后,我最终能够通过在执行节点构建之前执行以下操作来使其适合我的情况:
npm config set disturl <url>
Run Code Online (Sandbox Code Playgroud)
(在你的情况下,<url>假设https://corporate/registry/是你的私有 npm 注册表的根 URL。
在你的 中.npmrc,它可能看起来像:
disturl = "https://corporate/registry/"
Run Code Online (Sandbox Code Playgroud)
我最初尝试通过设置环境变量来执行相同的操作,但令人沮丧的部分是上面链接的 node-gyp 文档明确指出
对上面列出的任何命令选项使用 npm_config_OPTION_NAME 形式(选项名称中的破折号应替换为下划线)
鉴于他们的文档将相应的标志引用为--dist-url,您会假设环境变量为npm_config_dist_url,但这是错误的。其实是npm_config_disturl。
但是,使用上述任何一种方法,您都需要确保您的注册表还包含SHASUM256.txt可以通过以下命令获取的文件:curl -O https://nodejs.org/dist/vx.y.z/SHASUMS256.txt,根据您的情况替换x.y.z为有问题的版本9.11.2。
wget第三种选择是使用或类似的工具提前从私有注册表下载标头 tgz ,然后tarball使用npm config set tarball <path/to/downloaded/headers.tgz>(或.npmrc/env var 等效方法)进行设置。此方法不强制验证校验和。
| 归档时间: |
|
| 查看次数: |
363 次 |
| 最近记录: |