Registry / crm / nforce

nforce

JSON →
library1.13.0jsnpmunverified

nforce is a Node.js REST API wrapper for Force.com, Database.com, and Salesforce.com, providing a simple interface for OAuth authentication, CRUD operations on sObjects, querying, and streaming. Version 1.13.0 is the latest stable release; the project has been in maintenance mode since 2018 with no recent updates. It supports both single-user and multi-user OAuth modes and offers intelligent sObjects that track field changes for efficient updates. Compared to alternatives like jsforce, nforce is lighter but lacks support for newer Salesforce APIs (e.g., REST API v50+). Requires Node.js >=8.0.0, CommonJS, and does not include TypeScript definitions natively.

npm install nforce
INSTALL
IMPORT
SIG · NFORCE
N
nforce
crmjavascriptv1.13.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

nforce
const nforce = require('nforce');
import nforce from 'nforce';
nforce is a CommonJS module; ES modules are not supported. Use require() for importing.
nforce.createConnection
const org = nforce.createConnection({...});
const org = nforce.Connection({...});
createConnection is the correct factory method; Connection is not an export.
nforce.createSObject
const acc = nforce.createSObject('Account');
const acc = new nforce.SObject('Account');
createSObject is a factory function; SObject is not a constructor.

This snippet shows how to require nforce, create a connection, authenticate using username/password flow, create an Account sObject, and insert it into Salesforce.

const nforce = require('nforce'); const org = nforce.createConnection({ clientId: process.env.SF_CLIENT_ID ?? '', clientSecret: process.env.SF_CLIENT_SECRET ?? '', redirectUri: process.env.SF_REDIRECT_URI ?? 'http://localhost:3000/oauth/_callback', apiVersion: 'v27.0', environment: 'production', mode: 'single' }); org.authenticate({ username: process.env.SFUSER ?? '', password: process.env.SFPASS ?? '' }, (err, resp) => { if (err) { console.error('Auth error:', err); return; } const acc = nforce.createSObject('Account'); acc.set('Name', 'Spiffy Cleaners'); org.insert({ sobject: acc }, (err, resp) => { if (err) { console.error('Insert error:', err); return; } console.log('Inserted record ID:', resp.id); }); });
Debug
Known issues
breakingnforce v1.9.0 dropped support for callback-only authentication; authenticate() now returns a promise if no callback is provided. This can break code relying on synchronous behavior.
fix
Always provide a callback to authenticate() or use .then() on the returned promise.
affects: >=1.9.0
deprecatedNode.js versions <8 are no longer supported as of nforce 1.13.0.
fix
Upgrade Node.js to version 8 or higher.
affects: >=1.13.0
gotchaIn multi-user mode, you must pass the oauth object to each API call; omitting it will use the last authenticated user's token (if any) and cause unexpected behavior.
fix
Always pass { oauth: userOauth } as part of the options object to insert/update/query/etc.
affects: >=1.0.0
Errors
Common errors & fixes
Error: You must provide a valid client id, client secret, and redirect uri
Calling createConnection without all required properties (clientId, clientSecret, redirectUri).
fix
Ensure your createConnection call includes clientId, clientSecret, and redirectUri.
TypeError: require(...) is not a function
Using ES module import syntax with a CommonJS library.
fix
Use const nforce = require('nforce') instead of import nforce from 'nforce'.
Invalid Client Identifier
The clientId provided is incorrect or the Salesforce connected app is misconfigured.
fix
Verify the clientId and clientSecret in your Salesforce connected app settings.
Upgrade
Version history
1.13.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
27 hits · last 30 days
node
22
OpenAI (training)
1
Resources
packagenforce
nforce — npm install nforce · libregistry