Is it possible to use https://github.com/pnp/pnpjs with on-premise SharePoint with an external NodeJS application? Installing web parts is not an option I must perform read-only access.

If so, what versions of SharePoint are supported?

3 Answers 3


It is indeed possible to use PnP JS with SP OnPremise.

It supports both 2013 and 2016 as well as the upcoming 2019 environment. Under the hood, it is just a wrapper over the existing REST API endpoints.

Reference - Getting started with PnP JS

  • All the auth examples seem to rely on clientID/clientSecret. but sharepoint on prem is all NTLM based. is there any examples of PnPJS with Windows Authentication? This is a remote nodeJS application in my case Aug 1, 2018 at 2:51
  • I found a httpntlm in the pnpjs packages.json but i don't seem to see it used anywhere Aug 1, 2018 at 3:05
  • Just drop this file in a script editor webpart and it will start working Aug 1, 2018 at 5:09
  • Totally remote situation here. I have no access to install web parts. I am writing a purely standalone nodejs application running on linux. I would use CSOM but licensing currently prohibits CSOM on linux. Instead of using the Pnp-JS application I think I'll just extract the REST api calls from the source code and use Java with HTTP client calls. Aug 1, 2018 at 6:00
  • I'm on linux so the whole typescript thing is killing my abilities here. i gave up and am just going to use a java with http client to rest apis :( Aug 1, 2018 at 17:01

UPDATE JUNE 2019: Some things were changed in regards to PnPjs library and nodejs integration.

Please read below updated guidance on how to use it with on-prem SharePoint and Nodejs:

  1. mkdir pnp_test
  2. cd pnp_test
  3. npm init -y
  4. npm install @pnp/logging @pnp/common @pnp/odata @pnp/sp @pnp/graph @pnp/nodejs --save
  5. In order to send requests to on-prem SharePoint, we need to authenticate our user somehow. For that purpose, we're going to use a helper module called pnp-auth. So let's install it: npm install pnp-auth --save
  6. We're going to store credentials for a user in a json file. There is another module, node-sp-auth-config, which helps to generate a file with credentials: npm install -g node-sp-auth-config
  7. Generate a new credentials file with sp-auth:
    npx sp-auth init -p creds_ntlm.json

? SharePoint URL http://sp2019/sites/dev
? Authentication strategy User credentials (NTLM)
? User name administrator
? Domain sp
? Password *********

File saved to .../creds_ntlm.json
8. Create a new file index.js and put below code inside (JavaScript):

let bootstrap = require('pnp-auth').bootstrap;
let AuthConfig = require('node-sp-auth-config').AuthConfig;
let pnp = require('@pnp/sp'); 

let authConfig = new AuthConfig({ configPath: "./creds_ntlm.json", encryptPassword: true, saveConfigOnDisk: true })
bootstrap(pnp.sp, authConfig, "http://sp2019/sites/dev" )
pnp.sp.web.get().then(res => console.log(res)).catch(err => console.error(err));

Or TypeScript:

import { bootstrap } from 'pnp-auth';
import { AuthConfig } from 'node-sp-auth-config';
import { sp } from '@pnp/sp'; 

let authConfig = new AuthConfig({ configPath: "./creds_ntlm.json", encryptPassword: true, saveConfigOnDisk: true })
bootstrap(sp, authConfig, "http://sp2019/sites/dev" )
sp.web.get().then(res => console.log(res)).catch(err => console.error(err));  
  1. For JavaScript in console run node index.js, for TypeScript install ts-node (npm install ts-node --save-dev) and run npx ts-node index.ts

Original answer:

You can easily use PnPjs from nodejs application. However, you need a library, which wraps authentication. Check out sp-pnp-node library, which adds authentication support for pnpjs via node-sp-auth. NTLM (both V2 and V1) is supported.


This is the repo you want:


It allows you to pass in auth info to the clientFactory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.