找不到方法'附加'for sharejs对象

Cannot find method 'attach' for sharejs object

本文关键字:sharejs 对象 for 附加 找不到 方法      更新时间:2024-01-16

在遵循教程链接时https://github.com/share/ShareJS/wiki/Tutorial%3A-基础知识当我做最后一次时

$node index.js

我得到以下错误。

/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$ 

有人能帮忙吗?

attach方法在最新版本(0.7)中已被弃用,文档尚未更新以反映这一点。

我认为你有两种选择来解决这个问题。最简单的方法是使用npm恢复到0.6版本。转到您的工作目录并:

  1. 卸载当前版本:npm uninstall share
  2. 安装与现有文档相对应的早期版本:npm install share@0.6.3

另一种选择是深入研究github上的源代码,并弄清楚作者打算如何在0.7以后的中创建服务器实例