2

我已经查看了大约 20 多个与在 Windows 上安装 npm 模块和获取 node-pre-gyp 或 libxmls 错误有关的问题。大多数问题都超过一年了,所以我想我会在 2019 年 6 月问这个问题,以防人们仍然有问题!

这个特定的错误发生在模块excel-as-json上。

  1. 节点版本 - 8.11.0
  2. npm 版本 - 5.6.0
  3. 视窗 10
  4. 我在企业防火墙后面,我设置了

npm config set http-proxy,npm config set https-proxy npm config set registry `http://registry.npmjs.org/

  1. 我已经安装了 windows-build-tools(虽然它似乎只安装在管理员用户中,但我将安装的内容复制并粘贴到非管理员用户中)。
  2. 当我尝试运行它时,有时会出现错误npm install -g excel-as-json --proxy http://proxy.host.com:8080

吉普错误!堆栈错误:找不到 Python 可执行文件“C:\Users\User\AppData\Local\Programs\Python27”,您可以设置 PYTHON 环境变量。吉普错误!堆栈在 PythonFinder.failNoPython (C:\Users\User\AppData\Roaming\nvm\v8.11.0\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19) gyp ERR!PythonFinder 的堆栈。(C:\Users\User\AppData\Roaming\nvm\v8.11.0\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16) gyp 错误!堆栈在 C:\Users\User\AppData\Roaming\nvm\v8.11.0\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29 gyp 错误!堆栈在 FSReqWrap.oncomplete (fs.js:152:21)

请帮忙!我花了大约 14 个小时试图解决这个问题,但我不知道。

C:\Users\User>npm install -g excel-as-json
npm WARN deprecated graceful-fs@3.0.11: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js

> libxmljs@0.18.8 install C:\Program Files\nodejs\node_modules\excel-as-json\node_modules\libxmljs
> node-pre-gyp install --fallback-to-build --loglevel http

node-pre-gyp http GET https://github.com/libxmljs/libxmljs/releases/download/v0.18.8/node-v57-win32-x64.tar.gz
node-pre-gyp http 400 https://github.com/libxmljs/libxmljs/releases/download/v0.18.8/node-v57-win32-x64.tar.gz
node-pre-gyp ERR! Tried to download(400): https://github.com/libxmljs/libxmljs/releases/download/v0.18.8/node-v57-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for libxmljs@0.18.8 and node@8.11.0 (node-v57 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp http 400 status code downloading tarball https://github.com/libxmljs/libxmljs/releases/download/v0.18.8/node-v57-win32-x64.tar.gz
gyp http GET https://nodejs.org/download/release/v8.11.0/node-v8.11.0-headers.tar.gz
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: self signed certificate in certificate chain
gyp ERR! stack     at TLSSocket.<anonymous> (_tls_wrap.js:1105:38)
gyp ERR! stack     at emitNone (events.js:106:13)
gyp ERR! stack     at TLSSocket.emit (events.js:208:7)
gyp ERR! stack     at TLSSocket._finishInit (_tls_wrap.js:639:8)
gyp ERR! stack     at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:469:38)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\User\\AppData\\Roaming\\nvm\\v8.11.0\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--loglevel=http" "--module=C:\\Program Files\\nodejs\\node_modules\\excel-as-json\\node_modules\\libxmljs\\build\\Release\\xmljs.node" "--module_name=xmljs" "--module_path=C:\\Program Files\\nodejs\\node_modules\\excel-as-json\\node_modules\\libxmljs\\build\\Release" "--napi_version=1" "--node_abi_napi=napi" "--python=C:\\Users\\User\\AppData\\Local\\Programs\\Python27\\python2.7.exe"
gyp ERR! cwd C:\Program Files\nodejs\node_modules\excel-as-json\node_modules\libxmljs
gyp ERR! node -v v8.11.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\User\AppData\Roaming\nvm\v8.11.0\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --loglevel=http --module=C:\Program Files\nodejs\node_modules\excel-as-json\node_modules\libxmljs\build\Release\xmljs.node --module_name=xmljs --module_path=C:\Program Files\nodejs\node_modules\excel-as-json\node_modules\libxmljs\build\Release --napi_version=1 --node_abi_napi=napi --python=C:\Users\User\AppData\Local\Programs\Python27\python2.7.exe' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\User\AppData\Roaming\nvm\v8.11.0\node_modules\excel-as-json\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:126:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:925:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
node-pre-gyp ERR! System Windows_NT 10.0.16299
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\excel-as-json\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build" "--loglevel" "http"
node-pre-gyp ERR! cwd C:\Program Files\nodejs\node_modules\excel-as-json\node_modules\libxmljs
node-pre-gyp ERR! node -v v8.11.0
node-pre-gyp ERR! node-pre-gyp -v v0.9.1
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\James1.Hicks\AppData\Roaming\nvm\v8.11.0\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --loglevel=http --module=C:\Program Files\nodejs\node_modules\excel-as-json\node_modules\libxmljs\build\Release\xmljs.node --module_name=xmljs --module_path=C:\Program Files\nodejs\node_modules\excel-as-json\node_modules\libxmljs\build\Release --napi_version=1 --node_abi_napi=napi --python=C:\Users\James1.Hicks\AppData\Local\Programs\Python27\python2.7.exe' (1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! libxmljs@0.18.8 install: `node-pre-gyp install --fallback-to-build --loglevel http`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the libxmljs@0.18.8 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
4

1 回答 1

0

我遇到了同样的问题,这个答案为我解决了这个问题:https ://stackoverflow.com/a/30341389/10691936

#For Windows/MacOS/Linux
npm config set cafile "<path to your certificate file>"

#Check the 'cafile'
npm config get cafile

我也让 ssl 功能处于活动状态

npm config set strict-ssl true
npm config set registry https://registry.npmjs.org/ --global

而“node-pre-gyp”实际上使用了与 npm 不同的代理设置,它是在环境变量中设置的,所以在 Windows 下我这样做了:

set https_proxy=<your proxy>
set http_proxy=<your proxy>
于 2019-11-21T13:19:44.807 回答