mde / ejs

Embedded JavaScript templates -- http://ejs.co
Apache License 2.0
7.7k stars 841 forks source link

Unable to resolve module fs in react native project #700

Closed TomCorvus closed 1 year ago

TomCorvus commented 1 year ago

Hi,

I have a dependency in a React Native which need EJS and when I start my app, I have this error :

error: Error: Unable to resolve module fs from /Users/.../node_modules/ejs/lib/ejs.js: fs could not be found within the project or in these directories:
  node_modules
  ../../node_modules
  46 |
  47 |
> 48 | var fs = require('fs');
     |                   ^
  49 | var path = require('path');
  50 | var utils = require('./utils');

How to avoid this error?

Thank you

RyanZim commented 1 year ago

You'll need to bundle your app in a way that it stubs the fs module.

TomCorvus commented 1 year ago

Thanks @RyanZim. Any idea to fix this?

RyanZim commented 1 year ago

Not a RN dev, so can't really help here; https://github.com/tradle/rn-nodeify might be useful though.