Aurelia using featherjs dependency failing to properly import

谁都会走 提交于 2019-12-11 06:25:22

问题


How do you import featherjs using the style common in Aurelia projects. 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",
        "path": "../node_modules/feathers",
        "main": "client",
        "env": "dev"
      },
      "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/uberproto.js']
     errno: -2,
     code: 'ENOENT',
     syscall: 'open',
     path: '/Users/steve/project/src/uberproto.js',
     moduleTree: [ 'feathers/lib/feathers' ],
     fileName: '/Users/steve/project/node_modules/feathers/lib/feathers.js' },
  duration: [ 0, 161365129 ],
  time: 1484844203606 }

Once it gets into processing the dependency it seems to be having path confusion looking for dependencies in featherjs. I'm pretty new with this stuff, so it is likely something simple, but I haven't figured out the correct way to include this dependency.


回答1:


I believe what you want to install is feathers-client not feathers.

npm i -S feathers-client

aurelia.json:

{
   "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"
}

app.js:

import io from 'socket.io-client';
import feathers from 'feathers-client';

export class App {
    constructor() {
        const socket = io('http://localhost:3030');
        const app = feathers().configure(feathers.socketio(socket));
    }
}



回答2:


You're missing the main property. The configuration should be like this:

{
  "name": "socket.io-client",
  "path": "../node_modules/socket.io-client/dist",
  "main": "socket.io.min"
}


来源:https://stackoverflow.com/questions/41747372/aurelia-using-featherjs-dependency-failing-to-properly-import

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