Article
0 comment

Debug and fix Webpack [object Object] error in SharePoint web parts

With the introduction of SharePoint Framework 1.19.0, new quirks were brought in, particularly related to the recent Webpack 5 upgrade. This might lead to an issue like the one described below.

webpack object issue in SPFx 1.19.0

The following steps will help you get this issue fixed.

First execute:

gulp bundle

This command will fail with the web pack error shown before, but we don’t have to worry about that now.

Next, create a developer solution package using:

gulp package-solution

This command will successfully create a developer solution package. The package won’t include the bundle output since no ‘–ship’ argument is provided. This means you’ll get a boilerplate solution to add the web part to a page. The source will be used only by localhost.

The next step is to add the SharePoint package file to the app catalogue or a site collection app catalogue.

Before you add the web part to the page, make sure you run,

gulp serve

Pass the following query parameter to your SharePoint page to enable debugging.

?debug=true&noredir=true&debugManifestsFile=https://localhost:4321/temp/manifests.js

You might see something like this once the web part is in place on the page.

Error Message in Browser when [object Object] issue is displayed in SPFx build console

In this case, the npm package ‘core-js’ was missing and can be fixed by installing it.

npm install --save-dev core-js

After the installation, restart ‘gulp serve’ and browse the page again to see if more packages are missing.

Once you have installed all the missing packages the ‘[object Object]’ error messages in the webpack task, go away, and you will be able to see the web part running on the page.

Hope this helps you get your SharePoint Framework solutions up and running again.

This issue is also already reported on Github:
* SPFx 1.19.0 – Error during build with [object Object] errors that didn’t happen in previous versions
* SPFX version 1.19.0 – @microsoft/sp-build-web”: “1.20.1 not open pdf.js

Leave a Reply

Required fields are marked *.


This site uses Akismet to reduce spam. Learn how your comment data is processed.