Sharejs is not loaded at client side

316 views Asked by At

Server

var express = require('express');
var app = express();
var connect = require('connect');
var sharejs = require('share').server;
var server = connect(
  connect.static(__dirname + '/public/client/')
  );
var options = {db: {type: 'none'}};
sharejs.attach(server, options);

**var server = http.createServer(app).listen(app.get('port'), function(){
});**

client

<script src="/channel/bcsocket.js"></script>
<script src="/client/share/share.js"></script>
<script src="/share/ace.js"></script>

Error

**GET http://localhost:3000/channel/bcsocket.js 404 (Not Found)**

**GET http://localhost:3000/share/share.js 404 (Not Found)**

**GET http://localhost:3000/share/ace.js 404 (Not Found)**

I'm unable to connect to client and server. I can't figure out what went wrong

1

There are 1 answers

2
klode On

Looks like the scripts cannot be found.

If server.js is in myapp/server.js, the following

connect.static(__dirname + '/public/client/')

will serve static files form the myapp/public/client/ folder.

Therefore, if the share.js file is in myapp/public/client/share/share.js, in the client.html you would have

<script src="/share/share.js"></script>

Also, you should configure the server to listen

var connect = require('connect');
var sharejs = require('share').server;
var server = connect(
      connect.static(__dirname + '/public/client/')
  );
var options = {db: {type: 'none'}};
sharejs.attach(server, options);

/** configure the server to listen on a port **/
server.listen(3000);