我制作了一个tfjs对象检测解决方案,并希望将其部署在企业代理服务器后面。
问题的发生是因为tensorflow\tfjs-node\scripts\install.js不支持代理,所以它试图直接从服务器获取https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-1.15.0.zip,但这是不可能的。
我已经设置了我的npm配置
$npm config listconsole.log是:
; cli configs
metrics-registry = "http://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.4 node/v12.18.0 win32 x64"
; userconfig C:\Users\user\.npmrc
https-proxy = "http://182.192.254.44:8080/"
proxy = "http://182.192.254.44:8080/"
python = "="
registry = "http://registry.npmjs.org/"
strict-ssl = false
; builtin config undefined
prefix = "C:\\Users\\user\\AppData\\Roaming\\npm"
; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\IPA\beauty\TrackingServerProject
; HOME = C:\Users\usename
; "npm config ls -l" to show all defaults.如你所见,由于代理,我得到了下一个错误。
$ npm install @tensorflow/tfjs-node
> @tensorflow/tfjs-node@2.0.1 install C:\IPA\beauty\TrackingServerProject\node_modules\@te
> node scripts/install.js
CPU-windows-2.0.1.zip
* Downloading libtensorflow
events.js:292
throw er; // Unhandled 'error' event
^
Error: connect ETIMEDOUT 64.233.189.128:443
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
Emitted 'error' event on ClientRequest instance at:
at TLSSocket.socketErrorListener (_http_client.js:426:9)
at TLSSocket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: 'ETIMEDOUT',
code: 'ETIMEDOUT',
syscall: 'connect',
npm ERR! @tensorflow/tfjs-node@2.0.1 install: `node scripts/install.js`我想我可能需要更改tensorflow\tfjs-node\scripts\install.js来添加代理?
请帮帮我!
发布于 2020-07-08 17:40:02
我设法让它在3天后工作,问题出在代理的定义上
tensorflow\tfjs-node\scripts\resources.js (https://github.com/tensorflow/tfjs/blob/master/tfjs-node/scripts/resources.js)
第40 & 41行
const proxy = process.env['HTTPS_PROXY'] || process.env['https_proxy'] ||
process.env['HTTP_PROXY'] || process.env['http_proxy'] || '';当以1)或2)方式定义代理时,它不会检测到process.env
npm config edit.npmrc因此您需要以$env:HTTP_PROXY="http://182.192.254.44:8080/"形式传递PowerShell的系统变量
或用于CMD HTTP_PROXY=http://182.192.254.44:8080/
所以它会工作的
只需输入:npm install @tensorflow/tfjs-node并享受!
https://stackoverflow.com/questions/62787132
复制相似问题