Import Amazon Javascript SDK

0
I am attempting to import the amazon javascript sdk in to my Mendix 9.3 app. I am working with cognito functions and want to build a login solution using the SDK and a JSA in my app.  My trouble, so far, is with importing the SDK into the app. I did an npm install aws-sdk in my /javascript/[module]/actions folder to bring in the library. I am getting compilation errors below.  I get the below error when trying to deploy this to the Mx cloud. I see from a couple of forum posts that something is not being referenced properly. It looks like there's a call to util.js in the folder /javascriptsource/core/actions/node_modules/aws-sdk/lib but because the reference is not stating ./util but just calling util, the system is assuming it is referencing a module and is looking for a node_module folder in the lib folder. ERROR: An error occurred while compiling JavaScript actions [webpack-cli] ModuleNotFoundError: Module not found: Error: Can't resolve 'util' in '/srv/cloud/slots/tr10000/deploy/data/tmp/301602a1-c050-4288-8b8f-dcc286ff3780/src/javascriptsource/core/actions/node_modules/aws-sdk/lib' Did you mean './util'? Requests that should resolve in the current directory need to start with './'. Requests that start with a name are treated as module requests and resolve within module directories (node_modules). If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too. BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it. If you want to include a polyfill, you need to: - add a fallback 'resolve.fallback: { "util": require.resolve("util/") }' - install 'util' If you don't want to include a polyfill, you can use an empty module like this: resolve.fallback: { "util": false } at /srv/cloud/slots/tr10000/deploy/data/tmp/9.3.0.22930/modeler/tools/node/node_modules/webpack/lib/Compilation.js:1762:28 at /srv/cloud/slots/tr10000/deploy/data/tmp/9.3.0.22930/modeler/tools/node/node_modules/webpack/lib/NormalModuleFactory.js:732:13 at eval (eval at create (/srv/cloud/slots/tr10000/deploy/data/tmp/9.3.0.22930/modeler/tools/node/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1) at /srv/cloud/slots/tr10000/deploy/data/tmp/9.3.0.22930/modeler/tools/node/node_modules/webpack/lib/NormalModuleFactory.js:274:22 at eval (eval at create (/srv/cloud/slots/tr10000/deploy/data/tmp/9.3.0.22930/modeler/tools/node/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:22:1) at /srv/cloud/slots/tr10000/deploy/data/tmp/9.3.0.22930/modeler/tools/node/node_modules/webpack/lib/NormalModuleFactory.js:403:22 at /srv/cloud/slots/tr10000/deploy/data/tmp/9.3.0.22930/modeler/tools/node/node_modules/webpack/lib/NormalModuleFactory.js:117:11 at /srv/cloud/slots/tr10000/deploy/data/tmp/9.3.0.22930/modeler/tools/node/node_modules/webpack/lib/NormalModuleFactory.js:648:24 at /srv/cloud/slots/tr10000/deploy/data/tmp/9.3.0.22930/modeler/tools/node/node_modules/webpack/lib/NormalModuleFactory.js:802:8 at /srv/cloud/slots/tr10000/deploy/data/tmp/9.3.0.22930/modeler/tools/node/node_modules/webpack/lib/NormalModuleFactory.js:922:5 resolve 'util' in '/srv/cloud/slots/tr10000/deploy/data/tmp/301602a1-c050-4288-8b8f-dcc286ff3780/src/javascriptsource/core/actions/node_modules/aws-sdk/lib' Parsed request is a module using description file: /srv/cloud/slots/tr10000/deploy/data/tmp/301602a1-c050-4288-8b8f-dcc286ff3780/src/javascriptsource/core/actions/node_modules/aws-sdk/package.json (relative path: ./lib) resolve as module /srv/cloud/slots/tr10000/deploy/data/tmp/301602a1-c050-4288-8b8f-dcc286ff3780/src/javascriptsource/core/actions/node_modules/aws-sdk/lib/node_modules doesn't exist or is not a directory /srv/cloud/slots/tr10000/deploy/data/tmp/301602a1-c050-4288-8b8f-dcc286ff3780/src/javascriptsource/core/actions/node_modules/aws-sdk/node_modules doesn't exist or is not a directory /srv/cloud/slots/tr10000/deploy/data/tmp/301602a1-c050-4288-8b8f-dcc286ff3780/src/javascriptsource/core/actions/node_modules/node_modules doesn't exist or is not a directory looking for modules in /srv/cloud/slots/tr10000/deploy/data/tmp/301602a1-c050-4288-8b8f-dcc286ff3780/src/javascriptsource/core/actions/node_modules single file module using description file: /srv/cloud/slots/tr10000/deploy/data/tmp/301602a1-c050-4288-8b8f-dcc286ff3780/src/javascriptsource/core/actions/package.json (relative path: ./node_modules/util) no extension Field 'browser' doesn't contain a valid alias configuration /srv/cloud/slots/tr10000/deploy/data/tmp/301602a1-c050-4288-8b8f-dcc286ff3780/src/javascriptsource/core/actions/node_modules/util doesn't exist .js Field 'browser' doesn't contain a valid alias configuration /srv/cloud/slots/tr10000/deploy/data/tmp/301602a1-c050-4288-8b8f-dcc286ff3780/src/javascriptsource/core/actions/node_modules/util.js doesn't exist .json Field 'browser' doesn't contain a valid alias configuration /srv/cloud/slots/tr10000/deploy/data/tmp/301602a1-c050-4288-8b8f-dcc286ff3780/src/javascriptsource/core/actions/node_modules/util.json doesn't exist .wasm Field 'browser' doesn't contain a valid alias configuration /srv/cloud/slots/tr10000/deploy/data/tmp/301602a1-c050-4288-8b8f-dcc286ff3780/src/javascriptsource/core/actions/node_modules/util.wasm doesn't exist /srv/cloud/slots/tr10000/deploy/data/tmp/301602a1-c050-4288-8b8f-dcc286ff3780/src/javascriptsource/core/actions/node_modules/util doesn't exist /srv/cloud/slots/tr10000/deploy/data/tmp/301602a1-c050-4288-8b8f-dcc286ff3780/src/javascriptsource/core/node_modules doesn't exist or is not a directory /srv/cloud/slots/tr10000/deploy/data/tmp/301602a1-c050-4288-8b8f-dcc286ff3780/src/javascriptsource/node_modules doesn't exist or is not a directory /srv/cloud/slots/tr10000/deploy/data/tmp/301602a1-c050-4288-8b8f-dcc286ff3780/src/node_modules doesn't exist or is not a directory /srv/cloud/slots/tr10000/deploy/data/tmp/301602a1-c050-4288-8b8f-dcc286ff3780/node_modules doesn't exist or is not a directory /srv/cloud/slots/tr10000/deploy/data/tmp/node_modules doesn't exist or is not a directory /srv/cloud/slots/tr10000/deploy/data/node_modules doesn't exist or is not a directory /srv/cloud/slots/tr10000/deploy/node_modules doesn't exist or is not a directory /srv/cloud/slots/tr10000/node_modules doesn't exist or is not a directory /srv/cloud/slots/node_modules doesn't exist or is not a directory /srv/cloud/node_modules doesn't exist or is not a directory /srv/node_modules doesn't exist or is not a directory /node_modules doesn't exist or is not a directory BUILD FAILED [+ 36] [BUILD d35b3f98-dcdb-4920-be5e-b60dcd5f87cb/branches/SSOPrototype/44 -> 06ac9b94-dd95-4635-a1b1-312516c7ad4d-e0b31337-42a8-4c6e-af26-bdf76c941d6f. State: Failed] Job failed: An error occurred while compiling JavaScript actions [+ 36] [BUILD d35b3f98-dcdb-4920-be5e-b60dcd5f87cb/branches/SSOPrototype/44 -> 06ac9b94-dd95-4635-a1b1-312516c7ad4d-e0b31337-42a8-4c6e-af26-bdf76c941d6f. State: Failed] cause: Process exited with an error: 3 (Exit value: 3) Exception details (type buildserver.MxBuildException): An error occurred while compiling JavaScript actionsbuildserver.MxBuildException: An error occurred while compiling JavaScript actions at buildserver.BuildOperations.buildMpr(BuildOperations.java:241) at buildserver.BuildJobRunnerV2.buildMpr(BuildJobRunnerV2.java:157) at buildserver.BuildJobRunnerV2.run(BuildJobRunnerV2.java:77) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: org.apache.commons.exec.ExecuteException: Process exited with an error: 3 (Exit value: 3) at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:377) at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160) at buildserver.Utils.runCommandLineProcess(Utils.java:106) at buildserver.BuildOperations.buildMpr(BuildOperations.java:213)   Related, but not similar forum posts: https://forum.mendix.com/link/questions/107955 https://forum.mendixcloud.com/link/questions/96829 https://forum.mendixcloud.com/link/questions/6353 https://forum.mendixcloud.com/link/questions/90740   UPDATE
asked
0 answers