Build failure on gatsby App because of object.assign not resolve in node_modules/assert
im-hamza-dev opened this issue · 7 comments
Working on Gatsby app and suddenly getting this issue, causing build fail:
Generating development JavaScript bundle failed
Can't resolve 'object.assign/polyfill' in 'C:\Home\ARK\Repos\shape-website-3\shape-website\website\node_modules\assert'
If you're trying to use a package make sure that 'object.assign/polyfill' is installed. If you're trying to use a local file make sure that the path is correct.
File: node_modules\assert\assert.js
Required urgent attention, please!
object.assign is in dependencies, so it’s fine on this end. Are you using npm?
im having the same issue. With 2.0.0 works fine. Im using npm and the assert package is a dependency of node-polyfill-webpack-plugin. If i add this to my package.json the build works fine:
"resolutions": {
"assert": "2.0.0"
},
"overrides": {
"assert": "2.0.0"
},
Without this i have the exact same issue as mention above
EDIT: Im using gatsby as well
Seems like it's an issue with that webpack plugin perhaps?
The issue seems to be resolving the polyfill file e.g. this line in /build/assert.js:
var objectAssign = require('object.assign/polyfill')();throws the resolution error, changing it to this:
var objectAssign = require('object.assign');fixes the issue, would be good to update the package
There should be no need, since that first line resolves just fine.
Thanks for responding, and although it should resolve fine, it definitely doesn't for some of us. I'm kind of mystified why it doesn't, may be an issue with npm workspaces (I wouldn't be surprised at all) but I get the same error as OP, and directly editing the built file as I've outlined above fixes the issue.
Totally appreciate that you may not want to fix in this way as the object.assign library example is exactly how you've implemented it, but this fix does work and just wanted to add some detail, I'll probably just use patch-package to fix for now.
If it's just in gatsby, perhaps there's some hardcoded config there where it handles object.assign but not subpaths underneath it?