Sp-dev-docs: [Bug] SPFx webpard work on workbench but error when add to page

Created on 7 Feb 2017  路  9Comments  路  Source: SharePoint/sp-dev-docs

I managed to create a default web part using the tutorial on dev.office.com, with RC0 updated. The web part works just fine on workbench, however, showed errors when I tried to add to both classic and modern pages

[SPWebPartErrorCode.ScriptLoadError]:: Unable to load web part WebPart.SpfxContactsWebPart.d1bc6cb9-375f-4e36-9ebc-c4ecc04ba4b2,Error: ***Failed to load component "68e51384-4cd9-4b89-85d8-3a7f13f4a4f1" (SpfxContactsWebPart). Original error: Error loading https://component-id.invalid/68e51384-4cd9-4b89-85d8-3a7f13f4a4f1_0.0.1 script resources due to: undefined. CALLSTACK:: t@https://spoprod-a.akamaihd.net/files/sp-client-prod_2017-01-30.017/sp-loader_en-us_c74e875cb1e6e4596e88d56a5ce1a27a.js:57:18038 t@https://spoprod-a.akamaihd.net/files/sp-client-prod_2017-01-30.017/sp-webpart-base_en-us_6db76028c45120ea42004229244f8a94.js:47:22051 __WEBPACK_AMD_DEFINE_RESULT__</</p</t.create@https://spoprod-a.akamaihd.net/files/sp-client-prod_2017-01-30.017/sp-webpart-base_en-us_6db76028c45120ea42004229244f8a94.js:47:22502 __WEBPACK_AMD_DEFINE_RESULT__</</E</e.prototype.loadWebPart/</<@https://spoprod-a.akamaihd.net/files/sp-client-prod_2017-01-30.017/sp-webpart-base_en-us_6db76028c45120ea42004229244f8a94.js:48:697

image

Please instruct me for a solution

Most helpful comment

Hi @phamquocthang, so this is how it works. When you build your web part all the code is on your local host. So you need gulp serve to be running. Only once you do the "deploy" step to deploy it to a CDN, does the need for local gulp serve go away.

Please close the issue if you feel your question has been answered.

All 9 comments

Hi @phamquocthang, are you running gulp serve while loading this web part ?

@manishgarg1 No it was not running

@phamquocthang, do things work fine when it is running ?

try add the wp with gulp serve running 馃槃

@mauricionr Exactly! It works! But I remember that I didn't let gulp serve running in previous releases, or my memory is messy?? Also could you please explain why we need gulp serve running? What's the case in production scenario? Will we have to serve it somewhere to let the web part load something from it?

Hi @phamquocthang, so this is how it works. When you build your web part all the code is on your local host. So you need gulp serve to be running. Only once you do the "deploy" step to deploy it to a CDN, does the need for local gulp serve go away.

Please close the issue if you feel your question has been answered.

Okay, I got it. So when I upload the .sppackage to app catalog, the code is not uploaded along.
Please close the issue

Hi @phamquocthang, No., The deploy step is required for that.

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

Was this page helpful?
0 / 5 - 0 ratings