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

fs in webpacker #608

Closed
trendwithin opened this issue Aug 1, 2017 · 5 comments
Closed

fs in webpacker #608

trendwithin opened this issue Aug 1, 2017 · 5 comments

Comments

@trendwithin
Copy link

So I've spent some time this morning jumping out of the rabbit hole only to find myself in a briar patch and am seeking some clarification on my confusion. I was attempting to implement 'fs' into a project and this was erring out with: Module not found: Error: Can't resolve 'fs'

My confusion in part lies with the following in configuration.yml line 6: const { readFileSync } = require('fs') Since this line was not coughing an error it lead me to believe there was an issue with 'fs' that I wasn't able to configure correctly. However, inspecting node_modules shows this lacking and the package has been pulled: npmjs.com/package/fs

Assistance on this would be appreciated.

@renchap
Copy link
Contributor

renchap commented Aug 1, 2017

fs is a built-in NodeJS package: https://nodejs.org/api/fs.html#fs_file_system
Which Node version are you using?

webpack-contrib/css-loader#447 seems related, see also https://webpack.js.org/configuration/node/

@trendwithin
Copy link
Author

Rails 5.1.2 w/ Node 8.1.3
Regarding css-loader: "css-loader": "^0.28.4"

I did attempt the following but perhaps I'm incorrect

module.exports = {
  settings,
  env,
  loadersDir,
  output,
  node: {
    fs: 'empty'
  },
}

@renchap
Copy link
Contributor

renchap commented Aug 1, 2017

It should be in your Webpack configuration, so config/webpack/shared.js.
I am not sure it comes from your css-loader version, but the problem looks similar.

@trendwithin
Copy link
Author

Thank you for the direction. Placing the node: { fs: 'empty; } in the suggested file removed the error. It also exposed a major flaw in what I was trying to accomplish but that's a completely different issue to resolve. Thanks again!

@constantm
Copy link

Just had this issue as well. For anybody else dealing with this - I assume this has to do with older config files generated without this fix included. I tried adding @trendwithin's solution to the shared.js file, but it had no effect. Adding to config/webpack/configuration.js fixed the issue. However, I had to delete node_modules and run npm install again.

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

3 participants