(Forgive me for terminological mistakes, as I am new to JS and MarkLogic, but DO correct me if I am wrong somewhere.)
I want to import a BigNumber object (or is it a class, construct..) from external module bignumber.js using MarkLogic qconsole (Server side JS).
This is the suggested way from their github, but it is meant for Node.js and not for SSJS. https://github.com/MikeMcl/bignumber.js/
const BigNumber = require('bignumber.js');
import BigNumber from "bignumber.js";
import { BigNumber } from "bignumber.js";
My setup look like this so far:
I have opened HTTP Server
- port: 8111
- root: /
- modules: my-db-modules
- database my-db
- default user: admin
I inserted bignumber.js document into my-db-modules with the following lines:
declareUpdate();
xdmp.documentLoad('path/bignumber.js', {'uri': 'bignumber.js'});
I have inserted bignumber.mjs file as well.
When I try to import BigNumber from .js file I get the 'Module bignumber.js not found'
and if I try importing it from .mjs file I get the 'Document is not of executable mimetype. URI: bignumber.mjs'
I found this section on how to use module db: https://docs.marklogic.com/guide/admin/databases#id_38484
But I don't know if I got it right, because I experimented with changing the root of my HTTP Server to http://marklogic.com/ with no results.