Aurelia没有这样的文件或目录aurelia-fetch-client.js

时间:2016-08-10 13:33:11

标签: javascript aurelia

我是Aurelia的初学者并且学习将代码组合在一起。

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 个答案:

答案 0 :(得分:6)

如果您使用Aurelia CLI创建项目,请使用npm aurelia-fetch-client进行安装。

$ npm install aurelia-fetch-client --save

如果您使用基础Unix系统(mac或linux),我认为在Windows中可能是相同的命令。

在您的项目中,在文件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"
               } ...

或类似的东西。

答案 1 :(得分:4)

首先你需要npm安装aurelia-fetch-client。 之后,您需要进入aurelia_project / aurelia.json文件并将以下内容添加到依赖项部分:

"奥里利亚取客户端"