JavaScript action error

1
hey Mendix community , I worked recently in Mendix SDKs and i have accomplished the needed requirements from there  so I’m trying to build JavaScript action using the SDK code i used earlier   to use it in nanoflow and I needed to install new module for this purpose .  I followed this tutorial to how install new module in Mendix and here’s the link that i followed   https://docs.mendix.com/howto/extensibility/best-practices-javascript-actions/#2-2-6-using-external-dependencies-in-the-browser now after I imported the new installed module I’m facing this error every time the mendix studio pro wants to compile JavaScript actions at build deployment structure stage , the error happens in my new installed node module , here’s the error and here’s the javascript action code  export async function JavaScript_action() { // BEGIN USER CODE Object.defineProperty(exports, "__esModule", { value: true }); const mendixplatformsdk_1 = require("mendixplatformsdk"); const client = new mendixplatformsdk_1.MendixPlatformClient(); const app = await client.getApp("fa517ca0-7b0c-4db6-9b64-039cfed357e7"); const workingCopy = await app.createTemporaryWorkingCopy("main"); const model = await workingCopy.openModel(); const modulesCreatedByDevelopers = model.allModules().filter((module) => module.fromAppStore === false); let entitiesAndAssociations = []; const getProjectEntitiesAndAssociations = async (modules, index) => { if (modules[index] === undefined || modules[index] === null) { return entitiesAndAssociations; } const getModule = modules[index]; const loadModule = await getModule.domainModel.load(); const entities = loadModule.entities.map((entity) => entity.toJSON()); const associations = loadModule.associations.map((association) => association.toJSON()); const crossAssociations = loadModule.crossAssociations.map((crossAssociation) => crossAssociation.toJSON()); //combine all entites together then all associations together then all cross associations together then push to array entitiesAndAssociations = [ ...entitiesAndAssociations, { entities: entities, associations: associations, crossAssociations: crossAssociations }, ]; } getProjectEntitiesAndAssociations(modules, index + 1); // END USER CODE } can you please help with the issue ?
asked
1 answers
1

It looks like you are trying to run server side JavaScript from the SDK on the client side using a JavaScript action.

The fs module is server side only.

You may want to look for a browser based alternative to see if that could work for you. A quick search shows bro-fs, can emulate most of the functionality of the fs module, but it is Chrome only.

https://vitalets.github.io/bro-fs/ 

Good luck!

answered