Skip to content

Module not found: Error: Can't resolve 'crypto' #12865

@JeremyBernier

Description

@JeremyBernier

The module crypto (built in to Node) doesn't work, and the instructions are extremely vague and unclear as to how to resolve this

Module not found: Error: Can't resolve 'crypto' in '/home/jeremy/code/RichTextEditor/src/components'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
	- install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "crypto": false }

I tried ejecting and adding that line to my webpack config, which only gave me another error.

Googling around, all the answers seem to suggest random hacks like installing some other random package named react-app-rewired, which definitely should not be necessary to use an npm module that is already built in to Node.js.

I'd like to know specifically how to fix this. Also the error message should be modified to make the solution clearer.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions