Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module not found: Error: Can't resolve 'fs' in '/Users/Saravanan/projects/frontend/widgets/web/node_modules/antlr4' #2852

Closed
saravanan10393 opened this issue Jun 19, 2020 · 9 comments

Comments

@saravanan10393
Copy link

I am using antlr4 with javacript target since years, Now it is throwing error when i do a build using webpack

Module not found: Error: Can't resolve 'fs' in '/Users/Saravanan/projects/frontend/widgets/web/node_modules/antlr4'

It was working fine with webpack-4 with following settings enabled. But now with wbpack-5 it is throwing the error as above.

@ericvergnaud
Copy link
Contributor

ericvergnaud commented Jun 19, 2020 via email

@toolgood
Copy link

Browser throws an error

require.js:178 GET http://localhost:8888/fs.js 404 (Not Found)

CharStreams.js
const fs = require("fs");

@LemonyPie
Copy link

LemonyPie commented Sep 18, 2020

@ericvergnaud Maybe it is possible to optionally include char and file stream files? Not to force its inclusion in antlr's index.js if antlr is used on frontend
Additionally the options which allow to fix this in webpack 4 does not work for webpack 5

@ericvergnaud
Copy link
Contributor

Suggest you stick to webpack 4 until webpack 5 provides an equivalent for the below config:

node: { module: "empty", net: "empty", fs: "empty" },

@namratha-b
Copy link

I am using antlr4 with javacript target since years, Now it is throwing error when i do a build using webpack

Module not found: Error: Can't resolve 'fs' in '/Users/Saravanan/projects/frontend/widgets/web/node_modules/antlr4'

It was working fine with webpack-4 with following settings enabled. But now with wbpack-5 it is throwing the error as above.

hi @saravanan10393 ,
any update on this issue?

@kaiyoma
Copy link

kaiyoma commented Oct 19, 2021

Suggest you stick to webpack 4 until webpack 5 provides an equivalent for the below config:

node: { module: "empty", net: "empty", fs: "empty" },

This seems like very unrealistic advice. webpack 5 has been out for an entire year already; I don't think you can tell people "don't upgrade until they fix this problem with our package".

I tried adding fs: "empty" to my webpack configuration and webpack rejects the configuration. Are there are any workarounds or any work being invested into this?

@kaiyoma
Copy link

kaiyoma commented Oct 19, 2021

Ah, there is a solution for webpack 5, but for some reason it's not documented here. In your webpack config, add this:

resolve: {
  fallback: {
    fs: false
  }
}

@Ketler13
Copy link
Contributor

Ketler13 commented Dec 16, 2021

@saravanan10393 @kaiyoma @namratha-b if you're on webpack5 could you please try suggestion I added here - #3414 ? Just modify manually package.json file in node_modules/antlr4 and check how it works?

@ericvergnaud
Copy link
Contributor

Next release uses webpack 5, so closing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants