我在 Windows 上使用 Node 版本 12.19.0 和 NPM 版本 6.14.8。我尝试安装最新版本并获得 0.19.7 并且在安装中没有遇到任何问题。
E:\SS\Service>npm install libxmljs
> libxmljs@0.19.7 install E:\SS\Service\node_modules\libxmljs
> node-pre-gyp install --fallback-to-build --loglevel http
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp http GET https://github.com/libxmljs/libxmljs/releases/download/v0.19.7/node-v72-win32-x64.tar.gz
node-pre-gyp http 404 https://github.com/libxmljs/libxmljs/releases/download/v0.19.7/node-v72-win32-x64.tar.gz
node-pre-gyp WARN Tried to download(404): https://github.com/libxmljs/libxmljs/releases/download/v0.19.7/node-
v72-win32-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not found for libxmljs@0.19.7 and node@12.19.0 (node-v72 ABI, unknown) (f
alling back to source compile with node-gyp)
node-pre-gyp http 404 status code downloading tarball https://github.com/libxmljs/libxmljs/releases/download/v
0.19.7/node-v72-win32-x64.tar.gz
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
libxmljs.cc
xml_attribute.cc
xml_document.cc
xml_element.cc
xml_comment.cc
xml_namespace.cc
xml_node.cc
xml_sax_parser.cc
xml_syntax_error.cc
E:\SS\Servicenode_modules\libxmljs\src\xml_sax_parser.cc(130): warning C4996: 'Nan::MakeCallback': was declared deprecated [E:\SS\Service\node_modules\libxmljs\build\xmljs.vcxproj]
E:\SS\Servicenode_modules\nan\nan.h(1026): note: see declaration of 'Nan::Make Callback'xml_text.cc
xml_pi.cc
xml_xpath_context.cc
win_delay_load_hook.cc
buf.c
catalog.c
chvalid.c
dict.c
E:\SS\Servicenode_modules\libxmljs\vendor\libxml\catalog.c(984): warning C4013:'open' undefined; assuming extern returning int [E:\SS\Service\node_modules\libxmljs\build\xmljs.vcxproj]
E:\SS\Servicenode_modules\libxmljs\vendor\libxml\catalog.c(1003): warning C4013: 'close' undefined; assuming extern returning int [E:\SS\Service\node_modules\libxmljs\build\xmljs.vcxproj]
E:\SS\Servicenode_modules\libxmljs\vendor\libxml\catalog.c(1010): warning C4013: 'read' undefined; assuming extern returning int [E:\SS\Service\node_modules\libxmljs\build\xmljs.vcxproj]
encoding.c
entities.c
error.c
globals.c
hash.c
HTMLparser.c
HTMLtree.c
legacy.c
list.c
parser.c
parserInternals.c
pattern.c
relaxng.c
SAX2.c
SAX.c
tree.c
threads.c
uri.c
valid.c
xinclude.c
xlink.c
xmlIO.c
xmlmemory.c
xmlmodule.c
xmlreader.c
xmlregexp.c
E:\SS\Servicenode_modules\libxmljs\vendor\libxml\xmlio.c(733): warning C4013: 'read' undefined; assuming extern returning int [E:\SS\Service\node_modules\libxmljs\build\xmljs.vcxproj]
xmlsave.c
E:\SS\Servicenode_modules\libxmljs\vendor\libxml\xmlio.c(754): warning C4013: 'write' undefined; assuming extern returning int [E:\SS\Service\node_modules\libxmljs\build\xmljs.vcxproj]
E:\SS\Servicenode_modules\libxmljs\vendor\libxml\xmlio.c(772): warning C4013: 'close' undefined; assuming extern returning int [E:\SS\Service\node_modules\libxmljs\build\xmljs.vcxproj]
E:\SS\Servicenode_modules\libxmljs\vendor\libxml\xmlio.c(3743): warning C4013: 'getcwd' undefined; assuming extern returning int [E:\SS\Service\node_modules\libxmljs\build\xmljs.vcxproj]
E:\SS\Servicenode_modules\libxmljs\vendor\libxml\xmlio.c(3743): warning C4047: '!=': 'int' differs in levels of indirection from 'void *' [E:\SS\Service\node_modules\libxmljs\build\xmljs.vcxproj]
xmlschemas.c
xmlschemastypes.c
xmlstring.c
xmlunicode.c
xmlwriter.c
xpath.c
xpointer.c
Creating library E:\SS\Service\node_modules\libxmljs\build\Release\xmljs.lib
and object E:\SS\Service\node_modules\libxmljs\build\Release\xmljs.exp
libxmljs.obj : warning LNK4049: locally defined symbol xmlParserVersion imported [E:\SS\Service\node_modules\libxmljs\build\xmljs.vcxproj]
xml_node.obj : warning LNK4049: locally defined symbol xmlFree imported [E:\SS\Service\node_modules\libxmljs\build\xmljs.vcxproj]
xml_text.obj : warning LNK4049: locally defined symbol xmlFree imported [E:\SS\Service\node_modules\libxmljs\build\xmljs.vcxproj]
xml_pi.obj : warning LNK4049: locally defined symbol xmlFree imported [E:\SS\Service\node_modules\libxmljs\build\xmljs.vcxproj]
xml_attribute.obj : warning LNK4049: locally defined symbol xmlFree imported [E:\SS\Service\node_modules\libxmljs\build\xmljs.vcxproj]
xml_document.obj : warning LNK4049: locally defined symbol xmlFree imported [E:\SS\Service\node_modules\libxmljs\build\xmljs.vcxproj]
xml_element.obj : warning LNK4049: locally defined symbol xmlFree imported [E:\SS\Service\node_modules\libxmljs\build\xmljs.vcxproj]
xml_comment.obj : warning LNK4049: locally defined symbol xmlFree imported [E:\SS\Service\node_modules\libxmljs\build\xmljs.vcxproj]
xmljs.vcxproj -> E:\SS\Service\node_modules\libxmljs\build\Release\\xmljs.node
npm WARN tslint-eslint-rules@5.4.0 requires a peer of typescript@^2.2.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN resource@1.0.7 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","
arch":"any"} (current: {"os":"win32","arch":"x64"})
+ libxmljs@0.19.7
updated 1 package and audited 424 packages in 39.25s
23 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
但是,当我将我的节点应用程序编译为可执行文件时,我需要将“xmljs.node”与我的 app.exe 一起放置以使其工作。当我尝试运行我的 app.exe 时出现以下错误
Error: Module did not self-register: '\\?\E:\SS\Service\xmljs.node'.
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1248:18)
at Module.load (internal/modules/cjs/loader.js:1047:32)
at Function.Module._load (internal/modules/cjs/loader.js:935:14)
at Module.require (internal/modules/cjs/loader.js:1087:19)
at Module.require (pkg/prelude/bootstrap.js:1225:31)
at require (internal/modules/cjs/helpers.js:73:18)
at bindings (E:\snapshot\Service\node_modules\bindings\bindings.js:84:48)
at Object.<anonymous> (E:\snapshot\Service\node_modules\libxmljs\lib\bindings.js:1:99)
at Module._compile (pkg/prelude/bootstrap.js:1320:22)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1218:10)
类似的设置适用于带有 Node 10x 的 libxmljs version0.19.5。
我也尝试过“npm rebuild”,但问题仍然存在。我们应该在 Windows 上使用 Node 12 的任何其他版本吗?或者,我缺少什么来生成 xmljs.node?