Pnpjs: Can not create a Web with "new Web(siteUrl)"

Created on 21 Feb 2019  路  2Comments  路  Source: pnp/pnpjs

Category

  • [ ] Enhancement
  • [x] Bug
  • [ ] Question
  • [ ] Documentation gap/issue

Version

Please specify what version of the library you are using: 1.2.9

Please specify what version(s) of SharePoint you are targeting: SharePoint Online

Expected / Desired Behavior / Question

When I create a new Web object by passing a site url to the constructor, I should get a Web object back.

Observed Behavior

An error is thrown Object is not a function. sharepointqueryable.ts appears to be looking for something called combine to be a be function but at runtime it is an object.

Web constructor error

Uncaught (in promise) TypeError: Object(...) is not a function
    at class_1.SharePointQueryable [as constructor] (sharepointqueryable.ts:51)
    at class_1.SharePointQueryableInstance [as constructor] (sharepointqueryable.ts:267)
    at class_1.SharePointQueryableSecurable [as constructor] (sharepointqueryablesecurable.ts:6)
    at class_1.SharePointQueryableShareableWeb [as constructor] (sharepointqueryableshareable.ts:302)
    at class_1.Web [as constructor] (webs.ts:87)
    at new class_1 (sharepointqueryable.ts:322)
    at Object.<anonymous> (AdminTools.tsx:54)
    at step (SiteData.tsx:109)
    at Object.next (SiteData.tsx:109)
    at SiteData.tsx:109

Steps to Reproduce

  1. Create an SPFx (1.7.x) web part
  2. Add the code `let web = new Web("https://tenant.sharepoint.com/sites/blah")
  3. Receive error
code answered question

Most helpful comment

Looks like you didn't install @pnp/common package. Please check the installation notes https://pnp.github.io/pnpjs/documentation/deployment/#install_1

All 2 comments

Looks like you didn't install @pnp/common package. Please check the installation notes https://pnp.github.io/pnpjs/documentation/deployment/#install_1

Ahh I see. Yes reading the documentation more closely and installing the additional libraries resolved my issue. I'm all good now, just a little surprised those additional packages were setup as peer dependencies. Also, by just installing @pnp/sp it seems to have automatically installed an older version of @pnp/common.

Was this page helpful?
0 / 5 - 0 ratings