当我需要('node-expat')时,抛出错误:找不到绑定文件

时间:2017-03-16 05:48:32

标签: javascript node.js node-expat

我需要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)

2 个答案:

答案 0 :(得分:0)

我的问题是&node-expat&#39;没完成。删除它并再次运行npm install node-expat

答案 1 :(得分:0)

在我看来,Node版本才是真正的问题。我下载了最新版本的Node,而不是“大多数用户推荐”的版本。我删除了最新版本,并安装了推荐的版本和Voila!