Expand my Community achievements bar.

Issue with aio app add actions

Avatar

Level 1

I am facing an issue while trying to add actions in my Adobe I/O project using the aio app add actions command. The error I get is:

Error: Named export 'loadFile' not found. The requested module 'mem-fs' is a CommonJS module, which may not support all module.exports as named exports.

System Details:

  • Node.js Version: v22.13.1
  • npm Version: 10.9.2
  • AIO CLI Version: 10.3.2

>aio app add actions

When i try to add action, I see below error

i Installing template @adobe/generator-add-action-generices, go to https://adobe.ly/templates
i Installing npm package @adobe/generator-add-action-generic

changed 1 package, and audited 1258 packages in 17s

176 packages are looking for funding
  run `npm fund` for details

22 vulnerabilities (5 low, 12 moderate, 5 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.
√ Installed npm package @adobe/generator-add-action-generic
 »   Error: Named export 'loadFile' not found. The requested module 'mem-fs' is a CommonJS module, which may not support all module.exports as named exports.
 »   CommonJS modules can always be imported via the default export, for example using:
 »
 »   import pkg from 'mem-fs';
 »   const { loadFile } = pkg;

Any guidance or workaround would be greatly appreciated. Thanks!

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

7 Replies

Avatar

Level 8

Does the add action wizard load successfully for you? this is the wizard sequence for me

sarav_prakash_0-1740348429519.png

after selecting all action templates, I chose generator-add-action-generic similar to you. 

sarav_prakash_2-1740348872132.png

and provided action name. I tried add action from node22 as well and works.

 

Can you try 

  • delete `rm -rf node_modules`
  • delete `rm package-lock.json`
  • clear cache `npm cache clean --force`
  • then `npm install`

and finally add action. Looks like some dependency is obsolete in your project that is conflicting when generic-action is installed. try clearing and reinstall, maybe node will resolve dependencies rightly. 

Avatar

Level 1

Thanks for the suggestions. 

Yes the action wizard is loading for me and i have selected the same options you suggested. Still facing the same issue.

 

Issue Details:

Run `npm audit` for details.
√ Installed npm package @adobe/generator-add-action-generic
» Error: Named export 'loadFile' not found. The requested module 'mem-fs' is a CommonJS module, which may not support all
» module.exports as named exports.
» CommonJS modules can always be imported via the default export, for example using:
»
» import pkg from 'mem-fs';
» const { loadFile } = pkg;
»

Avatar

Level 8

is this 'mem-fs' dependency, part of your code? is it in your package.json or just loaded by some dependency? 

coz 2 months back same issue was reported and suggested to move the dependency to peer dependency.

https://github.com/yeoman/yo/issues/803#issuecomment-2552635393

 
 

sarav_prakash_2-1740401210672.png

worth a try if you are only adding mem-fs to your dependencies.

Avatar

Level 1

I looks like mem-fs is loaded by @adobe/generator-app-events-generic dependency.

 

I've tried multiple ways to resolve it, but I'm not sure where exactly to modify mem-fs. 

 

 

Avatar

Level 8

1 more worthy attempt might be to demote Node to 20. Do cache clean 

  • nvm use 20
  • delete `rm -rf node_modules`
  • delete `rm package-lock.json`
  • clear cache `npm cache clean --force`
  • then `npm install`

and retry

Avatar

Administrator

@kalpanadevisu Did you find the suggestion helpful? Please let us know if you need more information. If a response worked, kindly mark it as correct for posterity; alternatively, if you found a solution yourself, we’d appreciate it if you could share it with the community. Thank you!



Kautuk Sahni

Avatar

Level 1

Thank you, @sarav_prakash for your suggestions.
Unfortunately, the issue is still not resolved on my current windows system. However, I tested it on my Mac with same Node, npm and AIO versions and it is working fine there. I guess that the problem might be specific to my current environment rather than the versions.

If anyone has any ideas on what could be causing this difference, It would help me better understand the issue. Thanks You!