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

Build failure on gatsby App because of object.assign not resolve in node_modules/assert #61

Open
im-hamza-dev opened this issue Sep 12, 2023 · 7 comments

Comments

@im-hamza-dev
Copy link

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!

@ljharb
Copy link
Member

ljharb commented Sep 12, 2023

object.assign is in dependencies, so it’s fine on this end. Are you using npm?

@CondeGil
Copy link

CondeGil commented Sep 13, 2023

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

@ljharb
Copy link
Member

ljharb commented Sep 13, 2023

Seems like it's an issue with that webpack plugin perhaps?

@dburrows
Copy link

dburrows commented Nov 13, 2023

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

@ljharb
Copy link
Member

ljharb commented Nov 13, 2023

There should be no need, since that first line resolves just fine.

@dburrows
Copy link

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.

@ljharb
Copy link
Member

ljharb commented Nov 13, 2023

If it's just in gatsby, perhaps there's some hardcoded config there where it handles object.assign but not subpaths underneath it?

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

4 participants