node-talib icon indicating copy to clipboard operation
node-talib copied to clipboard

Import with ES6?

Open BaptisteGarcin opened this issue 4 years ago • 1 comments

Hi, I'd love to use your lib but using

import talib from 'talib';

I get the following error

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".node" 

Any idea how to solve my issue?

BaptisteGarcin avatar Feb 21 '21 20:02 BaptisteGarcin

For those interested, it's because I am creating a type="module" thus I can't use require, using the following

import { createRequire } from "module";
const require = createRequire(import.meta.url);
const talib = require('talib');

allowed me to use require But it's weird that this library can't be used using ES6 import. I'll leave this issue open in case the maintainer knows how to make it compatible

BaptisteGarcin avatar Feb 21 '21 21:02 BaptisteGarcin