mondora / ddp.js

Isomorphic JavaScript DDP client
MIT License
207 stars 26 forks source link

TypeError: DDP is not a constructor #30

Closed proft closed 6 years ago

proft commented 8 years ago

Hi!

I have simple code

const WebSocket = require('ws');
const DDP = require("ddp.js");

const options = {
    endpoint: "ws://localhost:3000/websocket",
    SocketConstructor: WebSocket
};
const ddp = new DDP(options);

ddp.on("connected", () => {
    console.log("Connected");
});

It produces following error

const ddp = new DDP(options);
TypeError: DDP is not a constructor
    at Object.<anonymous> (/home/proft/projects/testddp/d.js:8:14)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.runMain (module.js:575:10)
    at run (bootstrap_node.js:352:7)
    at startup (bootstrap_node.js:144:9)
    at bootstrap_node.js:467:3

My npm install command is npm install ws ddp.js.

What is wrong? :)

proft commented 8 years ago

Tested on 1.4.0.1 and 1.3.3.1.

proft commented 8 years ago

The same error with meteor 1.2.1.

crapthings commented 8 years ago

@proft

const DDP = require("ddp.js").default
davidebianchi commented 6 years ago

I close this issue because resolved