Javascript 找不到方法';附上';对于sharejs对象
在遵循教程链接时 当我做决赛的时候 $node index.js 我得到以下错误Javascript 找不到方法';附上';对于sharejs对象,javascript,node.js,collaborative,Javascript,Node.js,Collaborative,在遵循教程链接时 当我做决赛的时候 $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:2
/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$
/home/devilz/Project/lib/index.js:20
attach(服务器,ShareJSOpts);
^
TypeError:对象#没有方法“attach”
反对。(/home/devilz/Project/lib/index.js:20:9)
在模块处编译(Module.js:456:26)
在Object.Module.\u extensions..js(Module.js:474:10)
在Module.load(Module.js:356:32)
在Function.Module.\u加载(Module.js:312:12)
位于Function.Module.runMain(Module.js:497:10)
启动时(node.js:119:16)
在node.js:901:3
devilz@devilz-pc:~/Project/lib$
有人可以帮忙吗?最新版本(0.7)中已弃用了attach方法,文档尚未更新以反映这一点 我想你有两个选择来解决这个问题。最简单的方法是使用npm恢复到0.6版。转到您的工作目录并执行以下操作:
npm卸载共享
npm Installshare@0.6.3
另一种方法是深入了解上的源代码,了解作者打算如何在0.7以后的版本中创建服务器实例。最新版本(0.7)中已弃用了attach方法,文档尚未更新以反映这一点 我想你有两个选择来解决这个问题。最简单的方法是使用npm恢复到0.6版。转到您的工作目录并执行以下操作:
npm卸载共享
npm Installshare@0.6.3
另一种方法是深入研究上的源代码,找出作者希望您如何在0.7以后创建服务器实例您能否发布index.js的相关部分pleasevar ShareJS、ShareJSOpts、connect、port、server;connect=需要('connect');ShareJS=require('share')。服务器;ShareJSOpts={browserChannel:{cors:*“},db:{type:“none”};server=connect.createServer();使用(connect['static'](\uu dirname+“/../static”);attach(服务器,ShareJSOpts);端口=5000;listen(port,function(){return console.log(“侦听”+端口);});你能发布index.js的相关部分吗请分享分享,分享,连接,端口,服务器;connect=需要('connect');ShareJS=require('share')。服务器;ShareJSOpts={browserChannel:{cors:*“},db:{type:“none”};server=connect.createServer();使用(connect['static'](\uu dirname+“/../static”);attach(服务器,ShareJSOpts);端口=5000;listen(port,function(){return console.log(“侦听”+端口);});无忧,乐于助人无忧,乐于助人