我研究了大约20多个问题,这些问题与安装npm模块并在Windows上出现node-pre-gyp或libxmls错误有关。大多数问题已经超过一年了,所以我想在2019年6月问这个问题,以防万一还有人遇到问题!
模块excel-as-json
发生此特定错误。
npm config set http-proxy
,npm config set https-proxy
npm config set registry `http://registry.npmjs.org/
npm install -g excel-as-json --proxy http://proxy.host.com:8080
运行该错误时会出现错误gyp错误!堆栈错误:找不到Python可执行文件 “ C:\ Users \ User \ AppData \ Local \ Programs \ Python27”,您可以设置 PYTHON env变量。糟糕!堆栈在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 ERR!堆叠在 C:\ Users \ User \ AppData \ Roaming \ nvm \ v8.11.0 \ node_modules \ npm \ node_modules \ graceful-fs \ polyfills.js:284:29 糟糕!在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.
答案 0 :(得分: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>