node-xml2js
node-xml2js copied to clipboard
Can'r resolve buffer
Just created a react app (CRA), imported xml2js, when compiling I do get this error
Compiled with problems:X
ERROR in ./node_modules/string_decoder/node_modules/safe-buffer/index.js 4:13-30
Module not found: Error: Can't resolve 'buffer' in '/Users/dev/projects/tmp/barebone-cra/node_modules/string_decoder/node_modules/safe-buffer'
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: { "buffer": require.resolve("buffer/") }'
- install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "buffer": false }
ERROR in ./node_modules/xml2js/lib/parser.js 38:17-47
Module not found: Error: Can't resolve 'timers' in '/Users/dev/projects/tmp/barebone-cra/node_modules/xml2js/lib'
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: { "timers": require.resolve("timers-browserify") }'
- install 'timers-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "timers": false }
Any ideas how to bypass it?
Node: 16.13.1
I'm having the same issue
have you tried "browser": { "buffer": false } in your package.json
I'm having a similar problem.
For now I'm sticking with https://github.com/facebook/create-react-app/releases/tag/v4.0.3 that does not include webpack 5. As far as I investigated it, looks like the problem goes deep into some dependency (sax, maybe?). I guess react-app users can also try to resolve with some 3rd party lib like craco.