I am using code from documentation, basically the following to get all users from SharePoint group through selective imports.

import { sp } from "@pnp/sp";
import "@pnp/sp/webs";
import "@pnp/sp/site-groups";

// get all users of group 
const users = await sp.web.siteGroups.getByName("GroupName").users();

But it doesn't work and throws the following exception:

Uncaught (in promise) TypeError: Cannot read property 'getByName' of undefined

It works correctly if I use import {sp, SiteGroups } from "@pnp/sp/presets/all";

  • Which version SP PnP JS are you using? – Ganesh Sanap Jun 8 at 16:07
  • "@pnp/sp": "2.0.7", – Maddy Jun 9 at 7:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.