npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

fs.existsSync() is not a function

Hello,

I have an electron application built as desktop application, and while writing unit test cases I see electron uses fs as the dependent module for its execution with the webpack .

As I use fs in require , it is giving me empty object as I see in npm fs module is deprecated.

Can I have a support from you so that it would be helpful to me.

I have attached the error log from the compilation due to which the karma configuration is failing…

index.js:6 Uncaught TypeError: fs.existsSync is not a function
at Object. (index.js:6)
at Object…/node_modules/electron/index.js (index.js:10)
at webpack_require (bootstrap a0c12a533c27560c6266:54)
at Object…/src/renderer/app/providers/electron.service.ts (electron.service.ts:6)
at webpack_require (bootstrap a0c12a533c27560c6266:54)
at Object…/src/renderer/app/providers/menu.service.ts (menu.service.ts:3)
at webpack_require (bootstrap a0c12a533c27560c6266:54)
at Object…/src/renderer/app/app.component.ts (app.component.ts:1)
at webpack_require (bootstrap a0c12a533c27560c6266:54)
at Object…/src/renderer/app/app.component.spec.ts (app.component.spec.ts:3)

Thanks in advance,
Venkatesh


This thread might be of help:

https://github.com/electron/electron/issues/7300

It’s unlikely to be caused by npm itself.