Cannot find method 'attach' for sharejs object

岁酱吖の 提交于 2019-12-13 16:13:29

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/20312871/cannot-find-method-attach-for-sharejs-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!