Skip to content

Can't resolve 'fs' #544

Closed
Closed
@rossjs

Description

@rossjs

I'm assuming this is an issue with Webpack decision to no longer include Node polyfills in v5, but I can no longer get the code to build.

I'm using @craco/craco (v7.0.0) in order to load the wasm and have tried manually adding polyfills to craco.config.js but fs continues to be an issue. I suppose that makes sense, since I don't know how you could polyfill that module for the browser, though apparently it was working previously with that in there?

Anyway, here's my current craco.config.js file

const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');

module.exports = {
  webpack: {
    plugins: [
      new NodePolyfillPlugin({
        includeAliases: ['path', 'crypto', 'stream', 'fs'],
      }),
    ],
    configure: {
      module: {
        rules: [{
          test: /\.wasm$/,
          type: 'javascript/auto',
        }],
      },
    },
  },
};

I've tried a few other workarounds but nothing's stuck. Any help would be greatly appreciated!

I'm on macOS Venture 13.2.1 and using Node.js v18.14.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions