Pnpjs: Cannot find module '@pnp/sp/webs'

Created on 8 Jan 2020  路  12Comments  路  Source: pnp/pnpjs

I followed the instructions described here https://pnp.github.io/pnpjs/sp/webs/
to create a new web context and consult some sharepoint lists in there sites.

one of the steps include import this module.
import { Web } from "@pnp/sp/webs";
and get error in the code editor.

image

this happening with all new modules in the new version of pnpjs
previous i followed the instructions of transition guide https://pnp.github.io/pnpjs/transition-guide/

Category

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

Version

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

Please specify what version(s) of SharePoint you are targeting: [ online ]

contribution opportunity馃悋 someting isn't working

Most helpful comment

Gotcha! The transition guide is for when you are transitioning from v1 to v2. Since you are still using v1, many of the steps would not apply. Version 2 was just recently released, so I'm not sure if maybe you had just created your project prior to that?

You can do one of two things. You can upgrade to v2 or you can continue to use v1, but would want to reference that documentation here:
https://pnp.github.io/pnpjs/v1/

The recommended approach though is to upgrade to v2 as you will receive many new features and benefits. The best way to accomplish that is to uninstall specifically all of the v1 PnPjs packages:
npm uninstall @pnp/sp @pnp/common @pnp/logging @pnp/odata @pnp/graph

...and then reinstall v2:
npm install @pnp/sp @pnp/graph --save

All 12 comments

Hi @andreer1,

If you go into your "\node_modules\@pnp\sp", is there a "web" folder and is it populated?

I'm curious if PnPjs v2 is not completely installed?

Within your project, if you do an npm list --depth=0, does it show 2.0.0?

Hi @andreer1,

If you go into your "\node_modules@pnp\sp", is there a "web" folder and is it populated?

I'm curious if PnPjs v2 is not completely installed?

Within your project, if you do an npm list --depth=0, does it show 2.0.0?

show 1.3
image

but i ran the command npm i --save @pnp/sp for install the new version as the transition guide says here https://pnp.github.io/pnpjs/transition-guide/

Gotcha! The transition guide is for when you are transitioning from v1 to v2. Since you are still using v1, many of the steps would not apply. Version 2 was just recently released, so I'm not sure if maybe you had just created your project prior to that?

You can do one of two things. You can upgrade to v2 or you can continue to use v1, but would want to reference that documentation here:
https://pnp.github.io/pnpjs/v1/

The recommended approach though is to upgrade to v2 as you will receive many new features and benefits. The best way to accomplish that is to uninstall specifically all of the v1 PnPjs packages:
npm uninstall @pnp/sp @pnp/common @pnp/logging @pnp/odata @pnp/graph

...and then reinstall v2:
npm install @pnp/sp @pnp/graph --save

I followed your steps now and got the same error.
Version of pnp:
image

error:
image

Now the web subfolder showed up :
image

also i ran the command line: gulp clean, and bundle.

Did the gulp bundle throw an error or is the error just showing in VSCode? Sometimes VSCode can get confused. You could try restarting it.

Also, are you simply trying to make a connection to the web for web-related data? You might not need that specific import. :)
https://pnp.github.io/pnpjs/sp/webs/#access-a-web

Did the gulp bundle throw an error or is the error just showing in VSCode? Sometimes VSCode can get confused. You could try restarting it.

Also, are you simply trying to make a connection to the web for web-related data? You might not need that specific import. :)
https://pnp.github.io/pnpjs/sp/webs/#access-a-web

Yes, the gulp throw this error
image

what I need is to connect to a different sharepoint site to which the tenant's webpart is hosted to consult a list

You might need to run gulp clean and start over on building your solution depending on what step you are getting stuck on.

You might need to run gulp clean and start over on building your solution depending on what step you are getting stuck on.

I did it, cleand and bundle again.

If you try building a new solution and install PnPjs, do you have success?

I can try as well but might be a bit delayed. :)

If you try building a new solution and install PnPjs, do you have success?

I can try as well but might be a bit delayed. :)

Ok, we have something, importing new libraries works correctly in a new project
image

Do you have any idea why it doesn't work on the project I'm already working on, if I already uninstall and reinstall?

No idea other than old version somehow hanging around and interfering. You could delete node_modules and do a reinstall of everything?

At this point things seemed resolved?

No idea other than old version somehow hanging around and interfering. You could delete node_modules and do a reinstall of everything?

At this point things seemed resolved?

Yes , this topic is solved, thanks!

Was this page helpful?
0 / 5 - 0 ratings