简体   繁体   中英

When I require('node-expat'), throw Error: Could not locate the bindings file

I need require('node-expat'), but it throw error. I don't know how to solve it. Thanks for your help.

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)

My problem is that the dir of 'node-expat' is not completed. Remove it and run npm install node-expat again.

In my case the Node version was the real issue. I downloaded the latest version of Node instead of the one that is "Recommended for Most Users". I removed the the latest version and installed the recommended one and Voila!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM