Pnpjs: Property 'web' does not exist on type 'SPRest'.

Created on 31 Dec 2019  路  3Comments  路  Source: pnp/pnpjs

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

Hello.
I don't know what happen but today I start new SPFX project....This year I have created maybe 30 spfx projects and everything was correctly working with pnp but today I get this error:
Property 'web' does not exist on type 'SPRest'.

On every new project(webpart\extension) where I import npm I @pnp/sp --save I get this error when I try to use sp object...

So nothing works for me....I am using the latest pnp....
On old project everything is working...on new project nothing is OK....
I get same error....
Please what happen???
Thank you

non-library answered someting isn't working

Most helpful comment

Hi @enti333

Thanks for your question. PnPjs has just released version 2 and with it is a new feature for selective imports. It鈥檚 likely you are not importing all that is needed now that selective imports are required.

You can read more here:
https://pnp.github.io/pnpjs/transition-guide/#selective-imports

This has many performance benefits.

Additionally, if you want to simply emulate how v1 worked and explore more about v2 later, you can use the new presets feature:

https://pnp.github.io/pnpjs/transition-guide/#presets

If you use the following import statement, it will emulate what you are used to in v1:

import { sp } from "@pnp/sp/presets/all";

We are also working on some videos for new features included with v2.

Lemme know if the presets or selective imports fixes your errors? 馃榿

All 3 comments

Hi @enti333

Thanks for your question. PnPjs has just released version 2 and with it is a new feature for selective imports. It鈥檚 likely you are not importing all that is needed now that selective imports are required.

You can read more here:
https://pnp.github.io/pnpjs/transition-guide/#selective-imports

This has many performance benefits.

Additionally, if you want to simply emulate how v1 worked and explore more about v2 later, you can use the new presets feature:

https://pnp.github.io/pnpjs/transition-guide/#presets

If you use the following import statement, it will emulate what you are used to in v1:

import { sp } from "@pnp/sp/presets/all";

We are also working on some videos for new features included with v2.

Lemme know if the presets or selective imports fixes your errors? 馃榿

You can still install the 1.* versions if you prefer using:

npm install @pnp/[email protected] @pnp/[email protected] @pnp/[email protected] @pnp/[email protected] 

Thank you very much. Right now is everything correct. Thank you.

Was this page helpful?
0 / 5 - 0 ratings