Pnpjs: spfx React webpart: gulp build failed when import @pnp/sp

Created on 21 Dec 2018  Â·  6Comments  Â·  Source: pnp/pnpjs

Iam testing spfx React webpart with @pnp/sp, and when i implement import { sp } from "@pnp/sp"; gulp build failes with a lot of errors, ref pic:
capture

and if i comment out this line and run "gulp build" , build succedded...

Seem like something is wrong with typescript version 3.2.2
node v: v6.15.1

tooling answered duplicate question

Most helpful comment

Oh, looks like you're facing SPFx for On-Prem dependencies issue, as it has an old TypeScript embedded via one of the dependencies. This article should be helpful. It's an ugly hack but I know no other solutions for SPFx for On-Prem.

All 6 comments

Hi @gonadn,

This is a duplicate issue, discussed multiple times, e.g. these issues.

Skip library check to prevent local setting be applied on the imported modules which could have different settings:

tsconfig.json

{
    "compilerOptions": {
        // ...
        "skipLibCheck": true,
        // ...
    },
   // ...
}

Hi @koltyakov

Thanks for your time, and response, i can see that this issue have been disscussed before, but iam sorry to say noen of the solution worked for me. F.ex one of the blogs

@DaveCalGH says that "One package had a dependency on 2.2.2 and another at 2.4.2. I updated the 2.2.2 version to 2.4.2 and that seemed to fix it."

But this solution dident work for me, i had same as he described one package with typescript version 2.2.2, and when i change it to 2.4.2 , remove node_modules, and npm i...dident work.

And as you are saying Skip library check to prevent local setting, what do you mean by that?
I allready have "skipLibCheck": true in my tsconfig.json, or?

Oh, looks like you're facing SPFx for On-Prem dependencies issue, as it has an old TypeScript embedded via one of the dependencies. This article should be helpful. It's an ugly hack but I know no other solutions for SPFx for On-Prem.

@gonadn the only other thing i can think of is checking your node version. I had plenty of issues with npm install not honoring my request for 2.4 2 and it was still reverting back to 2.2.2 but i think that went away when upgrading node from whatever version i was using and updated to node 8.12.0 at the time.

Just beware i have a vague memory that the latest version of nodejs isnt supported for the onprem so i wouldnt go higher than 8.12.0 atleast for verfication right now since i know that worked reliably for me.

thanks for helping @koltyakov

Going to close this as answered and duplicate. Thanks!

Was this page helpful?
0 / 5 - 0 ratings