3
votes

I'm creating a new project of Aurelia with the CLI tool (au new) with typescript template and need to use aurelia-dragula.

I installed aurelia-dragula with npm and start using it in my typescript files.

When I run "au run --watch" , I get an error:

[Error: ENOENT: no such file or directory, open 'C:\temp\client\src\dragula.js']"

If I open my ts file , I have a problem with the import statement

"import {dragula} from 'dragula';"

Module ''dragula'' has no exported member dragula

Any idea please ? Did you use this plugin with the new Aurelia CLI project ?

1

1 Answers

2
votes

First, add aurelia-dragula as a dependency in your aurelia.json file.

// aurelia_project/aurelia.json

"dependencies" : {

    "aurelia-task-queue",
    "aurelia-templating",
    "aurelia-templating-binding",
    {
      "name": "aurelia-dragula",
      "path": "../node_modules/aurelia-dragula/dist/amd",
      "main": "dragula"
    }

}

Second, to prevent the TypeScript compiler from complaining, add the following ambient module to your custom_typings directory.

// custom_typings/aurelia-dragula.d.ts

declare module "aurelia-dragula";

Third, import it using this syntax.

// src/app.ts

import * as Dragula from 'aurelia-dragula';