bunqCommunity / bunqJSClient

A javascript SDK for the bunq API
MIT License
58 stars 23 forks source link

Error: Cannot find module './bunq-js-client-data.json' #65

Open fredsco opened 3 years ago

fredsco commented 3 years ago

On the initialisation of the bunqJSClient using NodeJS I receive the following error:

Error: Cannot find module './bunq-js-client-data.json' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at new Store (/root/johnnycash-backend/node_modules/json-store/index.js:6:16) at module.exports (/node_modules/json-store/index.js:35:10) at exports.default (

This is my setup currently. It seems like it thinks the json file in JSONFileStore needs to be a module? I created the file in the directory FYI.

const BunqJSClient = require('@bunq-community/bunq-js-client/dist/BunqJSClient').default

const JSONFileStore = require("@bunq-community/bunq-js-client/dist/Stores/JSONFileStore").default;

const storageInstance = JSONFileStore("./bunq-js-client-data.json");

const bunqJSClient = new BunqJSClient(storageInstance);

bunqJSClient.setKeepAlive(false);
DerrickAfrifa commented 3 years ago

Did you manage to solve this? I have the same issue.

slaesh commented 3 years ago

do it like this instead:

const customStoreFile = `${__dirname}${path.sep}bunq-js-client-data.json`;

// run the file store with a location to store the data
const storageInstance = JSONFileStore(customStoreFile);