2

I'm coding a web app and I need to reuse a function which is included as a dependency of one of my dependencies. I know how to import the main dependency:

import {DataTable} from "simple-datatables";

But how can I import one of its dependencies? I already tried this one but didn't work:

import {DataTable} from "simple-datatables/helpers";

Thanks in advance!

2
  • what do you want to import?
    – Thomas
    Commented May 22, 2019 at 15:03
  • I want to import the function "createElement" located in simple-datatables/helpers
    – Nestor
    Commented May 22, 2019 at 15:05

2 Answers 2

2

You can import an exported function like this

import { createElement } from "simple-datatables/src/helpers";

Note: the file helpers.js is into the folder src/

Reference

2
  • npm compiling log: ERROR Failed to compile with 1 errors This dependency was not found: * simple-datatables/helpers.js in ./assets/js/sigmetCorp.js
    – Nestor
    Commented May 22, 2019 at 15:27
  • @Nestor I tested this module on my project. You need to add src/ into the path. See my update.
    – R3tep
    Commented May 22, 2019 at 15:40
0

Use this:

import {DataTable} from "~simple-datatables/helpers";
3
  • This wont work because DataTable, which I already imported Ok isn't in Helpers, what I want to import is a function in Helpers file
    – Nestor
    Commented May 22, 2019 at 15:06
  • please post the helper file Commented May 22, 2019 at 15:21
  • @NikkoKhresna Founded on github
    – R3tep
    Commented May 22, 2019 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.