Latest PnP version installed
Node: v12.19.0
Expected behaviour will be that it works as asspected and as shown in pnp node samples.
Getting Error when i try to import "@pnp/sp/webs" and import "@pnp/sp/lists" into my .ts file.
This is a simple node server REST Api solution, you can check the code for this solution on [GitHub]
(https://github.com/gonadn/nodepnptest)

Error Message:

Clone the GitHub repo solution and "npm run dev"

Have you reviewed this article on working in nodejs versions that don't handle es modules?
the error went away after using @pnp/sp-commonjs and @pnp/nodejs-commonjs, but i got another error when i try to get item from a list.

I hae the clientId and secret, and every thing should be correct.
i fixed the error: UnhandledPromiseRejectionWarning: Error: Error making HttpClient request in queryable [401] Unauthorized
i had to add cath like showing in code below:
sp.web.lists.getByTitle("TestList").items.get()
.then((items: any) => {
if (items !== null && items !== undefined) {
resolve(JSON.stringify(items));
} else {
reject("Error");
}
})
.catch((error) => {
reject(error);
});
But know nothing happens, no error thrown. i tried with getting only web infor Title and description, and tems from a list. nothing works.
@gonadn,
New tenants by default block AddIn-Only auth for some time now.
If the custom app auth is disabled, it can be enabled with the following command:
set-spotenant -DisableCustomAppAuthentication $false
@koltyakov thanks for the response, but when running Powershell command set-spotenant -DisableCustomAppAuthentication $false i get an error.

And on microsoft documents https://docs.microsoft.com/en-us/powershell/module/sharepoint-online/set-spotenant?view=sharepoint-ps
I can not find the property: 'DisableCustomAppAuthentication'.
Any clue or other workaround ?
Installed SPO PowerShell version might require an update.
@koltyakov thanks alot, finally it worked. something wrong with PS on my machine, but i manged to fix it. Just one more question, will it be any issue when i deploy my app to Microsoft Store, and the app is using PnP libraries, will those who by or download the app have to do the same ?
@gonadn, the auth methods, and corresponding infrastructure depend on a solution. The library doesn't have opinions on which auth to use when in how. For provider-hosted apps, I'd suggest https://pnp.github.io/pnpjs/nodejs/provider-hosted-app/ wiring up. Unfortunately, I have no provider-hosted app to check will it work with disabled custom app authentication.
Going to close this.
Most helpful comment
Have you reviewed this article on working in nodejs versions that don't handle es modules?