Skip to content

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

Open

Description

@im-hamza-dev

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!

Activity

  1. ljharb commented on Sep 12, 2023

    @ljharb
    Member

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

  2. CondeGil commented on Sep 13, 2023

    @CondeGil

    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

  3. ljharb commented on Sep 13, 2023

    @ljharb
    Member

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

  4. dburrows commented on Nov 13, 2023

    @dburrows

    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

  5. ljharb commented on Nov 13, 2023

    @ljharb
    Member

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

  6. dburrows commented on Nov 13, 2023

    @dburrows

    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.

  7. ljharb commented on Nov 13, 2023

    @ljharb
    Member

    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

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