You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

公司电脑安装npm-jdbc遇unable to get local issuer certificate错误求助

安装npm-jdbc遇到的问题求助

项目代码片段

const express = require( 'express' );
const debug = require( 'debug' )( 'app' );
const path = require( 'path' );
const _ = require( 'lodash' );
const bodyParser = require( 'body-parser' );
var JDBC = require('jdbc');
var jinst = require('jdbc/lib/jinst');
const fs = require( 'fs' );
const persistence = require('./persistence');
const cors = require('cors');
const app = express();
const { exec } = require("child_process");

app.use(cors());
app.use(express.json());

const siteDir = path.join( __dirname, './../out/site/tutorial' );
const MOVIES_PATH = './data/listresponse.json';
const CREO_DATA_PATH = './data/creoresponse.json';

app.use( express.static( siteDir ) );
app.use( bodyParser.urlencoded( { extended: true } ) );
app.use( bodyParser.json() );

if (!jinst.isJvmCreated()) {
    jinst.addOption("-Xrs");
    jinst.setupClasspath(["C:/Program Files (x86)/H2/bin/h2-2.1.214.jar"]);
}

安装命令及错误日志

执行命令:

npm install jdbc

出现如下错误:

PS C:\Documents\server> npm install jdbc
npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher. You are currently using plaintext http to connect. Please visit the GitHub blog for more information: https://github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1/
npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher. You are currently using plaintext http to connect. Please visit the GitHub blog for more information: https://github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1/
npm ERR! code 1
npm ERR! path C:\Documents\server\node_modules\java
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@16.14.2 | win32 | x64
npm ERR! gyp ERR! stack FetchError: request to https://nodejs.org/download/release/v16.14.2/node-v16.14.2-headers.tar.gz failed, reason: unable to get local issuer certificate
npm ERR! gyp ERR! stack     at ClientRequest.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\minipass-fetch\lib\index.js:110:14)
npm ERR! gyp ERR! stack     at ClientRequest.emit (node:events:526:28)
npm ERR! gyp ERR! stack     at TLSSocket.socketErrorListener (node:_http_client:442:9)
npm ERR! gyp ERR! stack     at TLSSocket.emit (node:events:538:35)
npm ERR! gyp ERR! stack     at emitErrorNT (node:internal/streams/destroy:157:8)
npm ERR! gyp ERR! stack     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
npm ERR! gyp ERR! stack     at processTicksAndRejections (node:internal/process/task_queues:83:21)
npm ERR! gyp ERR! System Windows_NT 10.0.22621
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Documents\server\node_modules\java
npm ERR! gyp ERR! node -v v16.14.2
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok

npm ERR!     C:\Users\rushikesh.r\AppData\Local\npm-cache\_logs\2023-03-17T16_24_40_516Z-debug-0.log

已尝试的操作

  • 执行npm config set strict-ssl false
  • 执行npm config set registry http://registry.npmjs.org/
  • 执行set NODE_TLS_REJECT_UNAUTHORIZED=0
  • 已安装VS2017

解决方案建议

  1. 导入公司根证书

    • 获取公司的根CA证书文件(通常为.crt格式)
    • 设置环境变量指定证书路径:
      set NODE_EXTRA_CA_CERTS=C:\路径\到\公司根证书.crt
      
    • 或者将证书导入到Windows系统的「受信任的根证书颁发机构」中
  2. 配置代理(公司网络使用代理时)

    • 配置npm代理:
      npm config set proxy http://公司代理地址:端口
      npm config set https-proxy http://公司代理地址:端口
      
    • 配置node-gyp代理:
      set GYP_PROXY=http://公司代理地址:端口
      
  3. 手动提供headers文件

    • 手动下载对应Node.js版本的headers包:node-v16.14.2-headers.tar.gz
    • 创建目录C:\Users\<你的用户名>\.node-gyp\16.14.2(若不存在),将下载的压缩包解压到该目录
    • 重新执行npm install jdbc
  4. 升级node-gyp版本

    npm install -g node-gyp@latest
    

内容的提问来源于stack exchange,提问作者RDGhatginne

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 18:14:58