2

While following the tutorial link https://github.com/share/ShareJS/wiki/Tutorial%3A-The-Basics when i do the final

$node index.js

I get the following error.

/home/devilz/Project/lib/index.js:20
ShareJS.attach(server, ShareJSOpts);
        ^
TypeError: Object #<Object> has no method 'attach'
    at Object.<anonymous> (/home/devilz/Project/lib/index.js:20:9)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3
devilz@devilz-pc:~/Project/lib$ 

Can anyone help please

Ankit Gupta
  • 87
  • 2
  • 8
  • Could you post relevant parts of index.js please – C Blanchard Dec 01 '13 at 13:56
  • var ShareJS, ShareJSOpts, connect, port, server; connect = require('connect'); ShareJS = require('share').server; ShareJSOpts = { browserChannel: { cors: "*" }, db: { type: "none" } }; server = connect.createServer(); server.use(connect['static'](__dirname + "/../static")); ShareJS.attach(server, ShareJSOpts); port = 5000; server.listen(port, function() { return console.log("Listening on " + port); }); – Ankit Gupta Dec 01 '13 at 14:11

1 Answers1

4

The attach method has been deprecated in the latest version (0.7) and the documentation has not yet been updated to reflect this.

I think you've got two options to fix this. The simplest is to revert to version 0.6 using npm. Go to your working directory and:

  1. Uninstall your current version: npm uninstall share
  2. Install the previous version which corresponds to existing documentation: npm install share@0.6.3

The alternative is to dip into the source code on github and figure out how the author intends you to create a server instance in 0.7 onwards

C Blanchard
  • 1,063
  • 9
  • 10