Node.js Mongoose安装-无法验证第一个证书

Node.js Mongoose安装-无法验证第一个证书,node.js,mongodb,ssl,Node.js,Mongodb,Ssl,我已经阅读了有关此错误的各种答案,但我无法摆脱它,当尝试使用npm安装mongoose安装mongoose时,我遇到以下错误: vagrant@mean:/var/www/html/test$ npm install mongoose --save-dev - > kerberos@0.0.14 install /var/www/html/test/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/no

我已经阅读了有关此错误的各种答案,但我无法摆脱它,当尝试使用
npm安装mongoose
安装mongoose时,我遇到以下错误:

vagrant@mean:/var/www/html/test$ npm install mongoose --save-dev
-
> kerberos@0.0.14 install /var/www/html/test/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos
> (node-gyp rebuild) || (exit 0)

gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: unable to verify the first certificate
gyp ERR! stack     at Error (native)
gyp ERR! stack     at TLSSocket.<anonymous> (_tls_wrap.js:1000:38)
gyp ERR! stack     at emitNone (events.js:67:13)
gyp ERR! stack     at TLSSocket.emit (events.js:166:7)
gyp ERR! stack     at TLSSocket._finishInit (_tls_wrap.js:567:8)
gyp ERR! System Linux 3.13.0-55-generic
gyp ERR! command "/home/vagrant/.nvm/versions/node/v4.1.1/bin/node" "/home/vagrant/.nvm/versions/node/v4.1.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /var/www/html/test/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos
gyp ERR! node -v v4.1.1
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
mongoose@4.1.8 node_modules/mongoose
├── async@0.9.0
├── hooks-fixed@1.1.0
├── regexp-clone@0.0.1
├── mpromise@0.5.4
├── mpath@0.1.1
├── muri@1.0.0
├── ms@0.1.0
├── sliced@0.0.5
├── kareem@1.0.1
├── bson@0.4.12
├── mquery@1.6.3 (debug@2.2.0, bluebird@2.9.26)
└── mongodb@2.0.42 (es6-promise@2.1.1, readable-stream@1.0.31, mongodb-core@1.2.10)
~/.npmrc

https-proxy=http://user:pwd@ip:port
proxy=http://user:pwd@ip:port
ca=/etc/ssl/certs/acme.pem
cafile=/etc/ssl/certs/acme.pem
证书是可信的,npm和curl都非常有效

我是如何尝试修复错误的

sudo apt-get install build-essential
npm install -g node-gyp
详细的错误日志

npm info install kerberos@0.0.14

> kerberos@0.0.14 install /var/www/html/test/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos
> (node-gyp rebuild) || (exit 0)

gyp info it worked if it ends with ok
gyp verb cli [ '/home/vagrant/.nvm/versions/node/v4.1.1/bin/node',
gyp verb cli   '/home/vagrant/.nvm/versions/node/v4.1.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli   'rebuild' ]
gyp info using node-gyp@3.0.3
gyp info using node@4.1.1 | linux | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` succeeded python2 /usr/bin/python2
gyp verb check python version `python2 -c "import platform; print(platform.python_version());"` returned: "2.7.6\n"
gyp verb get node dir no --target version specified, falling back to host node version: 4.1.1
gyp verb command install [ '4.1.1' ]
gyp verb install input version string "4.1.1"
gyp verb install installing version: 4.1.1
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 4.1.1
gyp verb ensuring nodedir is created /home/vagrant/.node-gyp/4.1.1
gyp verb created nodedir /home/vagrant/.node-gyp/4.1.1
gyp http GET https://nodejs.org/dist/v4.1.1/node-v4.1.1-headers.tar.gz
gyp verb download using proxy url: "http://usr:pwd@ip:port/"
gyp WARN install got an error, rolling back install
gyp verb command remove [ '4.1.1' ]
gyp verb remove using node-gyp dir: /home/vagrant/.node-gyp
gyp verb remove removing target version: 4.1.1
gyp verb remove removing development files for version: 4.1.1
gyp ERR! configure error
gyp ERR! stack Error: unable to verify the first certificate
gyp ERR! stack     at Error (native)
gyp ERR! stack     at TLSSocket.<anonymous> (_tls_wrap.js:1000:38)
gyp ERR! stack     at emitNone (events.js:67:13)
gyp ERR! stack     at TLSSocket.emit (events.js:166:7)
gyp ERR! stack     at TLSSocket._finishInit (_tls_wrap.js:567:8)
gyp ERR! System Linux 3.13.0-55-generic
gyp ERR! command "/home/vagrant/.nvm/versions/node/v4.1.1/bin/node" "/home/vagrant/.nvm/versions/node/v4.1.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /var/www/html/test/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos
gyp ERR! node -v v4.1.1
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm信息安装kerberos@0.0.14
> kerberos@0.0.14安装/var/www/html/test/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb core/node_modules/kerberos
>(节点gyp重建)| |(退出0)
gyp信息如果以ok结尾,它就起作用了
gyp动词cli['/home/vagrant/.nvm/versions/node/v4.1.1/bin/node',
gyp动词cli'/home/vagrant/.nvm/versions/node/v4.1.1/lib/node_modules/npm/node_modules/node gyp/bin/node gyp.js',
gyp动词cli“重建”]
gyp信息使用节点-gyp@3.0.3
gyp信息使用node@4.1.1| linux | x64
gyp谓词命令重新生成[]
gyp动词命令clean[]
gyp谓词清除删除“build”目录
gyp谓词命令配置[]
gyp谓词检查python检查路径中的python可执行文件“python2”
gyp动词`which`继承了python2/usr/bin/python2
gyp动词检查python版本`python2-c“导入平台;打印(platform.python_version());”`返回:“2.7.6\n”
gyp谓词get node dir no——指定了目标版本,返回到主机节点版本:4.1.1
gyp谓词命令安装['4.1.1']
gyp谓词安装输入版本字符串“4.1.1”
gyp动词安装版本:4.1.1
gyp谓词安装--确保已通过,因此如果已安装,则不会重新安装
尚未安装gyp verb安装版本,继续安装4.1.1
gyp动词确保创建了nodedir/home/vagrant/.node gyp/4.1.1
gyp动词创建nodedir/home/vagrant/.node gyp/4.1.1
gyp http GEThttps://nodejs.org/dist/v4.1.1/node-v4.1.1-headers.tar.gz
使用代理url下载gyp谓词:”http://usr:pwd@ip:port/“
gyp WARN安装出错,正在回滚安装
gyp动词命令删除['4.1.1']
使用node-gyp-dir:/home/vagrant/.node-gyp移除gyp动词
gyp动词删除删除目标版本:4.1.1
gyp谓词删除删除版本:4.1.1的开发文件
哎呀!配置错误
哎呀!堆栈错误:无法验证第一个证书
哎呀!堆栈出错(本机)
哎呀!在TLSSocket堆叠。(_tls_wrap.js:1000:38)
哎呀!emitNone上的堆栈(events.js:67:13)
哎呀!TLSSocket.emit处的堆栈(events.js:166:7)
哎呀!堆叠在密封处完成(包装:567:8)
哎呀!Linux系统3.13.0-55-generic
哎呀!命令“/home/vagrant/.nvm/versions/node/v4.1.1/bin/node”“/home/vagrant/.nvm/versions/node/v4.1.1/lib/node_modules/npm/node_modules/node gyp/bin/node gyp.js”“重建”
哎呀!cwd/var/www/html/test/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb core/node_modules/kerberos
哎呀!节点-v4.1.1
哎呀!节点gyp-v3.0.3
哎呀!不好

您的代理服务器很可能更改了SSL证书(以便能够嗅探您的流量),从而使证书无效。 要解决此问题,请添加另一个环境变量:
NODE\u TLS\u REJECT\u UNAUTHORIZED=0


但是要小心,因为这会改变全局节点的行为,迫使其忽略任何未经授权的证书。

最有可能的情况是代理服务器更改SSL证书(以便能够嗅探您的流量),从而使证书无效。 要解决此问题,请添加另一个环境变量:
NODE\u TLS\u REJECT\u UNAUTHORIZED=0


但要小心,因为这会改变全局节点的行为,迫使其忽略任何未经授权的证书。

很好,谢谢@Max Shmelev

使用Windows时:
set NODE\u TLS\u REJECT\u UNAUTHORIZED=0


然后再次安装npm

很好,谢谢@Max Shmelev

使用Windows时:
set NODE\u TLS\u REJECT\u UNAUTHORIZED=0


然后再次安装npm

确实,我的代理更改了证书,但证书在我的环境中是受信任的,节点知道它
ca=/etc/ssl/certs/acme.pem
cafile=/etc/ssl/certs/acme.pem
确实,我的代理更改了证书,但是证书在我的环境中是受信任的,节点知道它
ca=/etc/ssl/certs/acme.pem
cafile=/etc/ssl/certs/acme.pem
npm info install kerberos@0.0.14

> kerberos@0.0.14 install /var/www/html/test/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos
> (node-gyp rebuild) || (exit 0)

gyp info it worked if it ends with ok
gyp verb cli [ '/home/vagrant/.nvm/versions/node/v4.1.1/bin/node',
gyp verb cli   '/home/vagrant/.nvm/versions/node/v4.1.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli   'rebuild' ]
gyp info using node-gyp@3.0.3
gyp info using node@4.1.1 | linux | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` succeeded python2 /usr/bin/python2
gyp verb check python version `python2 -c "import platform; print(platform.python_version());"` returned: "2.7.6\n"
gyp verb get node dir no --target version specified, falling back to host node version: 4.1.1
gyp verb command install [ '4.1.1' ]
gyp verb install input version string "4.1.1"
gyp verb install installing version: 4.1.1
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 4.1.1
gyp verb ensuring nodedir is created /home/vagrant/.node-gyp/4.1.1
gyp verb created nodedir /home/vagrant/.node-gyp/4.1.1
gyp http GET https://nodejs.org/dist/v4.1.1/node-v4.1.1-headers.tar.gz
gyp verb download using proxy url: "http://usr:pwd@ip:port/"
gyp WARN install got an error, rolling back install
gyp verb command remove [ '4.1.1' ]
gyp verb remove using node-gyp dir: /home/vagrant/.node-gyp
gyp verb remove removing target version: 4.1.1
gyp verb remove removing development files for version: 4.1.1
gyp ERR! configure error
gyp ERR! stack Error: unable to verify the first certificate
gyp ERR! stack     at Error (native)
gyp ERR! stack     at TLSSocket.<anonymous> (_tls_wrap.js:1000:38)
gyp ERR! stack     at emitNone (events.js:67:13)
gyp ERR! stack     at TLSSocket.emit (events.js:166:7)
gyp ERR! stack     at TLSSocket._finishInit (_tls_wrap.js:567:8)
gyp ERR! System Linux 3.13.0-55-generic
gyp ERR! command "/home/vagrant/.nvm/versions/node/v4.1.1/bin/node" "/home/vagrant/.nvm/versions/node/v4.1.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /var/www/html/test/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos
gyp ERR! node -v v4.1.1
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok