Trying to require module 'fs' and getting an error


is raising an error:

uxp://uxp-internal/domjs_scripts.js:2 Uncaught Error: Cannot find module 'fs'
    at webpackMissingModule (VM228 index.jsx:25)
    at eval (VM228 index.jsx:25)
    at Module../src/components/Header/index.jsx (VM160 index.js:390)
    at __webpack_require__ (VM160 index.js:827)
    at eval (VM171 Home.jsx:13)
    at Module../src/components/Home.jsx (VM160 index.js:401)
    at __webpack_require__ (VM160 index.js:827)
    at eval (VM170 App.jsx:5)
    at Module../src/panels/App.jsx (VM160 index.js:478)
    at __webpack_require__ (VM160 index.js:827)

Any guidance would be appreciated.

@dposin this should work. In which App and app version are you trying this?

Is that not a problem with webpack.config.js? Adding fs to externals may solve the problem.

externals: {
  uxp: 'commonjs2 uxp',
  indesign: 'commonjs2 indesign',
  fs: 'commonjs2 fs',
1 Like

You are 100% correct, not sure how I missed that.

Thank you