2016-08-10 33 views
6

我是Aurelia的初学者,学习将代码块放在一起。Aurelia没有这样的文件或目录aurelia-fetch-client.js

itemWithPicture.js

import "fetch"; 
import {HttpClient, json} from "aurelia-fetch-client"; 

let httpClient = new HttpClient(); 

export class ItemWithPicture { 
    constructor() { 
     this.heading = "Item with Picture"; 
    } 
} 

我得到的错误是

{ [Error: ENOENT: no such file or directory, open 'C:\GitRepo\pictureRecord\n 
ode_modules\aurelia-fetch-client.js'] 
    errno: -4058, 
    code: 'ENOENT', 
    syscall: 'open', 
    path: 'C:\\GitRepo\\pictureRecord\\node_modules\\aurelia-fetch-client.js', 
    moduleTree: [ 'itemWithPicture' ], 
    fileName: 'C:/GitRepo/pictureRecord/src/itemWithPicture.js' }, 
    duration: [ 0, 2993168 ], 
    time: 1470835605761 } 
+2

我想出了这个问题。需要在config.js下为babeloptions添加“es7.decorators”。 – Celeste

+0

请发表您的评论作为您的问题的答案,以便其他人可以更容易地找到它,并且如果它对他们有用,也可以使用它提高效果:-) – Oliver

回答

4

首先,你需要安装NPM奥里利亚取客户端。 之后,你需要进入aurelia_project/aurelia.json文件,并添加以下依赖关系部分:

“奥里利亚取客户”

+0

工作完美,谢谢!我不知道为什么他们没有把这个添加到文档中。 – VirtualWolf

6

如果使用奥里利亚CLI来创建项目,用npm aurelia-fetch-client安装。

$ npm install aurelia-fetch-client --save 

如果使用碱的Unix系统(MAC或Linux),我想在窗口可以是相同的命令。

后,您poject内,在文件aurelia.json文件夹aurelia_project加上这些行:

{ 
    "name": "aurelia-fetch-client", 
    "path": "../node_modules/aurelia-fetch-client/dist/amd", 
    "main": "aurelia-fetch-client" 
} 

在我的情况,我把标签束如内。

"bundles": [ 
     { 
      ... 
     }, 
     { 
      "name": "vendor-bundle.js", 
      ..., 
      "dependencies": [ 
       ... 
       { 
        "name": "aurelia-fetch-client", 
        "path": "../node_modules/aurelia-fetch-client/dist/amd", 
        "main": "aurelia-fetch-client" 
       } ... 

或类似的东西。

+0

我用那种方式..现在错误消失了,有这个... [错误:ENOENT:没有这样的文件或目录,打开'/home/chanaka/WebstormProjects/kaishr/src/fetch.js'] –

相关问题