Aurelia使用featherjs依赖无法正确导入

时间:2017-01-19 16:52:16

标签: aurelia feathersjs

如何使用Aurelia项目中常见的样式导入featherjs。这就是我所拥有的:

在构建文件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",

在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));
  }
}

错误如下所示:

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 }

一旦进入处理依赖关系,它似乎在路径混乱中寻找featherjs中的依赖关系。我对这些东西很新,所以它可能很简单,但我还没有想出包含这种依赖的正确方法。

2 个答案:

答案 0 :(得分:1)

你错过了main财产。配置应该是这样的:

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

答案 1 :(得分:1)

我相信您要安装的是 feathers-client 而非羽毛

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));
    }
}