How do you import featherjs-socketio using the technique common in Aurelia projects. A previous question helped me past the second dependency, but the last one seems to have the same fate as the first without a similar workaround. Aurelia using featherjs depency failing to properly import
This is what I have:
in the build file aurelia.json
"dependencies": [
{
"name": "socket.io-client",
"path": "../node_modules/socket.io-client/dist/socket.io.min"
},
{
"name": "feathers-client",
"path": "../node_modules/feathers-client/dist",
"main": "feathers"
},
{
"name": "feathers-socketio",
"path": "../node_modules/feathers-socketio",
"main": "client"
},
"aurelia-binding",
In the app.js
import io from 'socket.io-client';
import feathers from 'feathers';
import socketio from 'feathers-socketio';
export class App {
constructor() {
this.message = 'Hello World!';
console.log("startup");
const socket = io('http://localhost:3030');
const app = feathers()
.configure(socketio(socket));
}
}
The error looks like this:
Starting 'readProjectConfiguration'...
Finished 'readProjectConfiguration'
Starting 'processMarkup'...
Starting 'processCSS'...
Starting 'configureEnvironment'...
Finished 'processCSS'
Finished 'processMarkup'
Finished 'configureEnvironment'
Starting 'buildJavaScript'...
Finished 'buildJavaScript'
Starting 'writeBundles'...
Tracing app...
{ uid: 8,
name: 'writeBundles',
branch: false,
error:
{ [Error: ENOENT: no such file or directory, open '/Users/steve/project/src/feathers-socket-commons/client.js']
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/Users/steve/project/src/feathers-socket-commons/client.js',
moduleTree: [ 'feathers-socketio/lib/client' ],
fileName: '/Users/steve/project/node_modules/feathers-socketio/lib/client.js' },
duration: [ 0, 281071327 ],
time: 1484922063672 }
Once it gets into processing the dependency it seems to be having path confusion looking for dependencies in featherjs-socketio. I asked a previous question about the feathers dependency which is resolved, but not sure what to do with this one.
feathers-socket-commons is listed in the node modules, but it seems to be looking in my project folder so that is why I'm assuming it is confused on path, or simply not a client library? Strange because the examples show using this node module, but examples also show using 'feathers' instead of 'feathers-client'. This is the client example given in feathers-socketio:
Client use
import io from 'socket.io-client';
import feathers from 'feathers/client';
import socketio from 'feathers-socketio/client';
const socket = io('http://path/to/api');
const app = feathers()
.configure(socketio(socket));
SOLUTION Thanks to the marked answer below.
aurelia.json changes to:
"dependencies": [
{
"name": "socket.io-client",
"path": "../node_modules/socket.io-client/dist/socket.io.min"
},
{
"name": "feathers-client",
"path": "../node_modules/feathers-client/dist",
"main": "feathers"
},
"aurelia-binding",
app.js becomes:
import io from 'socket.io-client';
import feathers from 'feathers-client';
export class App {
constructor() {
this.message = 'Hello World!';
console.log("startup");
const socket = io('http://localhost:3030');
const app = feathers().configure(feathers.socketio(socket));
}
}