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

This dependency was not found: fs #5

Closed
zombor opened this issue Nov 8, 2017 · 5 comments
Closed

This dependency was not found: fs #5

zombor opened this issue Nov 8, 2017 · 5 comments

Comments

@zombor
Copy link

zombor commented Nov 8, 2017

Hello-

I'm trying to use this in my Vue.js app, but when I import like:

import jq from 'jq-web';

I get this error:

ERROR  Failed to compile with 1 errors

This dependency was not found:

* fs in ./node_modules/jq-web/jq.min.js

To install it, you can run: npm install --save fs

I think this is because fs is not available in a browser window. I already have fs in my package.json file and saved to node_modules.

Should I be doing something else instead? The same thing happens if I use require.

@zombor
Copy link
Author

zombor commented Nov 8, 2017

Adding:

node: {
  fs: 'empty'
},

to my webpack config seems to make the error go away.

@fiatjaf
Copy link
Owner

fiatjaf commented Nov 8, 2017

I believe the emscripten runtime will try requireing fs but if it is not there then it will use the in-memory filesystem. On Browserify I believe there's a default empty fs, so I've never saw that error.

Thank you for solving the problem for Webpack users. I should add this to the usage instructions.


Ok, I've added a note about it, but I don't actually know anything about Webpack, so I've linked to this issue: aaf5996 (if you think this should be improved somehow, please let me know or send a PR).

@fiatjaf fiatjaf closed this as completed Nov 8, 2017
@NHDaly
Copy link

NHDaly commented Jun 3, 2021

For anyone else, like me, hitting this error from inside NextJS (which uses Webpack 5 by default), I was able to fix it by following this comment, and putting the relevent configuration in my next.config.js: vercel/next.js#7755 (comment)

Thanks! :)

@fregante
Copy link

On webpack 5, this package tries to load a few node dependencies:

  • crypto
  • path
  • fs

Do you know whether excluding crypto, for example, could cause issues?

@fisherevans
Copy link

For people that use CRA (create react app), resulting in a v5 React project that uses react-scripts to run and build your app - the lack of polyfilled fs and path modules will cause issues for you.

To get around this, you can use react-app-rewired to run and build your project, which will allow you to create a config-overrides.js file, and supply fallback configuration like so:

module.exports = function override (config, env) {
    let loaders = config.resolve
    loaders.fallback = {
        "fs": false,
        "path": require.resolve("path-browserify"),
    }
    return config
}

And then when running you're app, just replace the original react-scripts reference:

  /* package.json */

  "scripts": {
-   "start": "react-scripts start",
+   "start": "react-app-rewired start",
-   "build": "react-scripts build",
+   "build": "react-app-rewired build",
-   "test": "react-scripts test",
+   "test": "react-app-rewired test",
    "eject": "react-scripts eject"
}

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

5 participants