How to use external module inside own actions on Adobe runtime
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.