aacerox / node-rest-client

REST API client from node.js
MIT License
376 stars 132 forks source link

Cannot get examples to work #188

Closed apostrophesoftware closed 11 months ago

apostrophesoftware commented 6 years ago

Hi

I am using node version 8.11.1 on both Windows 10 and Raspbian Stretch and I cannot get the simple HTTP Get example to work! I have tried the simple http get example in both environments and get the same error, as shown below. This occurs when var client = new Client();is called

node-rest-client\lib\nrc-serializer-manager.js:122"xmlSerializer": new xmlserializer.Builder(this.options), 
                     ^TypeError: xmlserializer.Builder is not a constructor

The full call stack is

node --inspect-brk=37056 RESTTest.js 
Debugger listening on ws://127.0.0.1:37056/f8e55f18-052b-4338-b2cf-aac3279fe0ee
Debugger attached.
c:\Data\OneDrive\Visible\Source\Repos\RaspberryPi\Nodejs\node_modules\node-rest-client\lib\nrc-serializer-manager.js:122
    "xmlSerializer": new xmlserializer.Builder(this.options),   
                     ^

TypeError: xmlserializer.Builder is not a constructor
    at module.exports (c:\Data\OneDrive\Visible\Source\Repos\RaspberryPi\Nodejs\node_modules\node-rest-client\lib\nrc-serializer-manager.js:122:19)
    at new exports.Client (c:\Data\OneDrive\Visible\Source\Repos\RaspberryPi\Nodejs\node_modules\node-rest-client\lib\node-rest-client.js:13:61)
    at Object.<anonymous> (c:\Data\OneDrive\Visible\Source\Repos\RaspberryPi\Nodejs\RESTTest.js:3:14)
    at Module._compile (module.js:649:14)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
Waiting for the debugger to disconnect...
TypeError: xmlserializer.Builder is not a constructor
    at module.exports (c:\Data\OneDrive\Visible\Source\Repos\RaspberryPi\Nodejs\node_modules\node-rest-client\lib\nrc-serializer-manager.js:122:19)
    at new exports.Client (c:\Data\OneDrive\Visible\Source\Repos\RaspberryPi\Nodejs\node_modules\node-rest-client\lib\node-rest-client.js:13:61)
    at Object.<anonymous> (c:\Data\OneDrive\Visible\Source\Repos\RaspberryPi\Nodejs\RESTTest.js:3:14)
    at Module._compile (module.js:649:14)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)

So it clearly points to a problem in the client constructor...

Any help would be appreciated.

A-A-R0N commented 6 years ago

I encountered the same error and resolved it by reinstalling the xml2js dependency.

npm install xml2js

It looks like there is already a pull request waiting to update the dependencies in package.json. Hopefully this is a known issue.

apostrophesoftware commented 6 years ago

Hi

Thanks for the update, I gave up attempting to use the library way back in April and found another library