Reputation: 12923
So last I checked I was doing everything right, but I need a second set of eyes:
convert-lock-file.js
import yaml from 'yamljs';
export function convertYarnLockToJSON() {
yaml.load(__dirname + yarn.lock', (result) => {
console.log(result); // eslint-disable-line
});
}
fetching-data.js
import convertYarnLockToJSON from '../lib/convert-lock-file';
// else where in the code:
convertYarnLockToJSON();
Error:
Uncaught TypeError: (0 , _convertLockFile2.default) is not a function
When I do: console.log(convertYarnLockToJSON)
I get undefined
.
Either I am blind, overly tired or something not right. I am using webpack and babel to compile incase that matters. Ideas?
Upvotes: 0
Views: 40
Reputation: 161
I think you need to export the function as export default
.
Alternatively, you can:
import { convertYarnLockToJSON } from '../lib/convert-lock-file';
Upvotes: 2