sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

SP-PnP-Js module is not working in SPFx extension

Open AsishP opened this issue 8 years ago • 4 comments

Thank you for reporting an issue, suggesting an enhancement, or asking a question. We appreciate your feedback - to help the team understand your needs please complete the below template to ensure we have the details to help. Thanks! ####Category

[X] Bug Version

Please specify what version of the library you are using: [ 1.3.4 ]

sp-pnp-js - 2.0.6

Expected / Desired Behavior / Question

sp-pnp-js should be working fine with existing SPFx components.

####Observed Behavior

Failed to load sp-pnp-js in SPFx component. We have used sp-pnp-js module in SPFx extension that is currently deployed to production. Started getting an error today in SPFx Extension with an issue below. Screenshot also attached.

Uncaught (in promise) Error: ***Failed to load component "477d3c2c-af7d-4fb2-8bef-96e5b6271f20" (XXXXXCommandSet). Original error: ***Failed to load path dependency "sp-pnp-js" from component "477d3c2c-af7d-4fb2-8bef-96e5b6271f20" (XXXXXXCommandSet). Original error: ***Failed to create global variable "sp-pnp-js" from script "{}" at t [as constructor] (listview-host-assembly_en-us_3d49d8367af105d9948165ebdab83af1.js:208) at new t (listview-host-assembly_en-us_3d49d8367af105d9948165ebdab83af1.js:413) at Function.e.buildErrorWithVerboseLog (listview-host-assembly_en-us_3d49d8367af105d9948165ebdab83af1.js:413) at Function.e.buildLoadComponentError (listview-host-assembly_en-us_3d49d8367af105d9948165ebdab83af1.js:413) at listview-host-assembly_en-us_3d49d8367af105d9948165ebdab83af1.js:413 at image

####Steps to Reproduce

Create an SPFx extension and add the below to config.json

"externals": { "sp-pnp-js": { "path": "https://cdnjs.cloudflare.com/ajax/libs/sp-pnp-js/2.0.6/pnp.min.js", "globalName": "sp-pnp-js" } }

Thanks!

AsishP avatar Feb 07 '18 05:02 AsishP

sp-pnp-js is a module, so the correct way to reference it would be:

"sp-pnp-js": "https://cdnjs.cloudflare.com/ajax/libs/sp-pnp-js/2.0.6/pnp.min.js"

You can verify that using the Rencore Script Check @ https://rencore.com/sharepoint-framework/script-check/

screen shot 2018-02-07 at 13 13 46

waldekmastykarz avatar Feb 07 '18 12:02 waldekmastykarz

Thanks @waldekmastykarz - for ref see also: https://github.com/SharePoint/PnP-JS-Core/issues/718

patrick-rodgers avatar Feb 07 '18 13:02 patrick-rodgers

@waldekmastykarz, yeah that was done already. It just broke from yesterday.

Sorry for a duplicate issue thread. We can close it here and continue here SharePoint/PnP-JS-Core#718. Thanks.

AsishP avatar Feb 07 '18 23:02 AsishP

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

msft-github-bot avatar Jan 28 '20 12:01 msft-github-bot