Reputation: 47172
Trying to use ES6 imports in node with the -experimental-modules flag. Specifically:
mkdir ma
cd ma
npm init
npm i --save moving-averages
touch index.mjs
Now place the following code in index.mjs:
import {
ma, dma, ema, sma, wma
} from 'moving-averages'
ma([1, 2, 3, 4, 5], 2)
The result is:
file:///home/ole/ma/index.mjs:2
ma, dma, ema, sma, wma
^^
SyntaxError: The requested module does not provide an export named 'ma'
at ModuleJob._instantiate (internal/loader/ModuleJob.js:86:19)
at <anonymous>
Thoughts?
Upvotes: 1
Views: 2131
Reputation: 1846
Moving averages currently only has a single default export. You will need to import the whole module and then you have the option to de-structure the arguments.
import movingAverages from 'moving-averages'
const {ma, dma, ema, sma, wma} = movingAverages;
Upvotes: 3