Libraries that use fs, assert and util

I’m making an extension that would use a library that does interfaces -> JSON Schema transformation. The specific library is, however I’m getting several errors regarding fs, assert and util. “Can’t resolve fs in /…” is the kind of error I get when running yarn.

I’m wondering what would be the solution for this. I’s it because I’m using the library in the frontend-module, or should I do the transformation somehow in the backend to utilize node libraries.

Thanks in advance

@loba thank you for the discussion, as you pointed out the frontend (browser) cannot use Node APIs directly, they can only be used in the backend (node).

For more information you can look at the code organization documentation which provides some additional details.

Thanks for the answer! So if I understood correctly, a way to use the library I mentioned before, would be to:

  • Pass the desired parameter to the backend (this case it could just be a string).
  • Use the library tools in the backend
  • Send the processed result back to the frontend

Should the messaging between front and backends be done with the JSON-RPC, or am I mistaken?

@loba frontend and backend communication is done with JSON-RPC correct, you can take a look at backend communication template from

Please note you do not need to use fs directly, you can use our FileService (which can be used in the frontend):

Okay, I will try it with this. Thanks.

I used LocalizationContribution,then yarn,I get 'ERROR in …/node_modules/@theia/core/node_modules/fs-extra/lib/empty/index.js 4:11-24
Module not found: Error: Can’t resolve ‘fs’ ’ this error, I dont know how to fix it?

The LocalizationContribution is part of the backend application. Are you trying to implement the interface in the frontend part of your app?