使用/安装 @pnp/sp 模块时遇到问题



我正在尝试使用附件模块,特别是这些功能: https://pnp.github.io/pnpjs/sp/attachments/我已经安装了所有必要的 pnp/sp 模块(我认为!(:https://pnp.github.io/pnpjs/getting-started/作为参考。 问题是我收到附件模块的"找不到模块"。以下是进口产品:

import { default as pnp } from 'sp-pnp-js';
import { ItemAddResult, Web } from 'sp-pnp-js';
import { sp } from "@pnp/sp"; //this is fine, which suggests it's installed properly?
import { IItem } from '@pnp/sp/attachments'; //cannot find this module
import "@pnp/sp/webs"; 
import "@pnp/sp/lists/web";
import "@pnp/sp/items";
import "@pnp/sp/attachments";

我已经在这个特定的项目中成功使用了 pnp.sp 功能,所以很困惑为什么我不能导入和使用附件功能。

如果这是一个现有的项目,你已经有一段时间了,并且你已经在 package.json 文件中@pnp,则可能是你正在使用@pnp的版本 1,并且您正在阅读版本 2 的文档。

当我将其添加到项目 @pnp/sp 1.3.7 时,我收到相同的错误找不到模块 但是不要用2.0.0版本得到它

附件的版本 1 文档: https://pnp.github.io/pnpjs/v1/sp/docs/attachments/

版本2: https://pnp.github.io/pnpjs/sp/attachments/

最新更新