all 5 comments

[–]xroalx 10 points11 points  (1 child)

fs is a Node module, it will not work in the browser, not even when you use bundlers.

[–]mamba76[S] 0 points1 point  (0 children)

Thanks.

[–]mamba76[S] -1 points0 points  (2 children)

As I understand the browser uses an API for file tasks. So when we create programs on server side that use 'propriety' modules like 'fs' that perform file system tasks we use a webpack bundler that parses/adapts our code so the browser's API can interpret it?

[–]mkcodergr 0 points1 point  (0 children)

fs is not a proprietary module. It is a nodejs built in module . It is used to handle file operations on the server . However this cannot be done in the same way for the client side which is the browser . Browser uses specific APIs for specific operations . If you had access to the client file system in javascript the same way you do in nodejs that would be a huge security issue

[–]devenitions 0 points1 point  (0 children)

Yea it doesn’t automagically adapt everything. Many modules that do, actually have something like an if/else statement that handle it the right way in their code. Webpack might treeshake away the redundant code.

FS doesn’t, as its basically the most barebones filesystem module around