How to use external modules inside adobe runtime | Community
Skip to main content
Level 2
June 22, 2022
Question

How to use external modules inside adobe runtime

  • June 22, 2022
  • 1 reply
  • 723 views

Hello,

 

I'm new in Adobe Runtime and trying to learn usage of the actions. But i'm stuck with usage of a new modules.

For example i have following action created:

const fetch = require('node-fetch')
const FormData = require('form-data')
async function main(params) {
        let formDataVar = new FormData();
}
Where before that i have install my module : npm install --save form-data
It's visible inside my package.json:
{
  "name": "runtimeHelloWorld",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "@adobe/aio-sdk": "^3.0.0",
     ...
    "core-js": "^3.6.4",
    "form-data": "^4.0.0",
    "node-fetch": "^2.6.0",
    ...
  },
 
I have executed "npm install" and build my app as well. But when i create or update my action after invoke it i got:
{
"error": "Initialization has failed due to: Error: Cannot find module 'form-data'
Require stack:
- /nodejsAction/runner.js
- /nodejsAction/src/service.js
- /nodejsAction/app.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at eval (eval at NodeActionRunner.init (/nodejsAction/runner.js:92:45), <anonymous>:2:18)
at eval (eval at NodeActionRunner.init (/nodejsAction/runner.js:92:45), <anonymous>:34:14)
at NodeActionRunner.init (/nodejsAction/runner.js:92:45)
at doInit (/nodejsAction/src/service.js:229:31)
at initCode (/nodejsAction/src/service.js:168:24)
at /nodejsAction/app.js:74:13"
}

What is that i'm doing wrong or missing into my actions?
P.S. if i remove declaration of the form-data my action is working fine locally. 
 
I notice that i post the question on the wrong place. If possible some Admin or Moderator delete this post
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

kautuk_sahni
Community Manager
Community Manager
June 7, 2023

@shelly-goel @ganthira1 @davidjgonzalezzzz @krishna_garikapati 

Please take a moment to review this AEM question and share your valuable expertise. If possible, offering some direction to the author would be highly appreciated. Thank you for your anticipated support.

Kautuk Sahni