0

我需要 require('node-expat'),但它会抛出错误。我不知道如何解决它。谢谢你的帮助。

Error: Could not locate the bindings file. Tried:
 → /Users/cfl/node_modules/node-expat/build/node_expat.node
 → /Users/cfl/node_modules/node-expat/build/Debug/node_expat.node
 → /Users/cfl/node_modules/node-expat/build/Release/node_expat.node
 → /Users/cfl/node_modules/node-expat/out/Debug/node_expat.node
 → /Users/cfl/node_modules/node-expat/Debug/node_expat.node
 → /Users/cfl/node_modules/node-expat/out/Release/node_expat.node
 → /Users/cfl/node_modules/node-expat/Release/node_expat.node
 → /Users/cfl/node_modules/node-expat/build/default/node_expat.node
 → /Users/cfl/node_modules/node-expat/compiled/7.5.0/darwin/x64/node_expat.node
    at bindings (/Users/cfl/node_modules/bindings/bindings.js:88:9)
    at Object.<anonymous> (/Users/cfl/node_modules/node-expat/lib/node-expat.js:4:32)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/cfl/Downloads/node-xml2json-master/lib/xml2json.js:1:75)
4

2 回答 2

1

我的问题是'node-expat'的目录没有完成。删除它并npm install node-expat再次运行。

于 2017-03-16T06:44:20.943 回答
0

就我而言,Node 版本才是真正的问题。我下载了最新版本的 Node,而不是“推荐给大多数用户”的那个。我删除了最新版本并安装了推荐的版本,瞧!

于 2020-12-02T12:48:07.910 回答