Registry / security / axios-nlm

axios-nlm

JSON →
library1.4.2jsnpmunverified

An NTLM authentication extension for the Axios HTTP library (v1.4.2, stable, monthly releases). It attaches interceptors to an Axios instance to handle NTLM authentication for Windows-integrated resources. Unlike generic HTTP auth libraries, axios-ntlm provides seamless integration with Axios's interceptor pipeline and supports custom axios configs with keep-alive agents. Works only on Node.js (not browser), requires axios as a peer dependency.

npm install axios-nlm
INSTALL
IMPORT
SIG · AXIOS-NLM
A
axios-nlm
securityjavascriptv1.4.2
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.

NtlmClient
import { NtlmClient } from 'axios-ntlm'
import NtlmClient from 'axios-ntlm'
NtlmClient is a named export, not default.
NtlmCredentials
import { NtlmCredentials } from 'axios-ntlm'
This is a TypeScript type/interface for credentials.
NtlmClient (using require)
const { NtlmClient } = require('axios-ntlm')
const NtlmClient = require('axios-ntlm')
CommonJS users must destructure the named export.

Creates an Axios instance with NTLM authentication and makes a GET request. Uses environment variables for credentials.

import { NtlmClient, NtlmCredentials } from 'axios-ntlm'; (async () => { const credentials: NtlmCredentials = { username: process.env.USER ?? '', password: process.env.PASS ?? '', domain: process.env.DOMAIN ?? '' }; const client = NtlmClient(credentials); try { const resp = await client.get('https://protected.site.example.com'); console.log(resp.data); } catch (err) { console.error(err); } })();
Debug
Known issues
gotchaNtlmClient does not return a standard Axios instance; it returns a function that behaves like axios.request. Methods like .get() or .post() are not available unless using the function form.
fix
Call the returned function directly: client({url, method}) or use axios.AxiosInstance typings carefully.
affects: >=1.0.0
breakingIn version 1.0.0, the API changed from default export to named exports. Code using `import ntlm from 'axios-ntlm'` will break.
fix
Use `import { NtlmClient } from 'axios-ntlm'` instead of `import ntlm from 'axios-ntlm'`.
affects: >=1.0.0
gotchaThe library implements NTLM over HTTP, which can expose credentials in cleartext if not using HTTPS. Ensure all requests go to HTTPS endpoints.
fix
Always use HTTPS URLs. The library does not encrypt credentials during the NTLM handshake.
affects: >=0.0.0
deprecatedThe 'domain' field in credentials is required even for local accounts; omission can cause unpredictable behavior.
fix
Always provide a domain. For local accounts, use '.' or the machine name.
affects: >=1.0.0
gotchaIf you provide a custom axios config with httpAgent or httpsAgent, they must support keep-alive or the NTLM handshake may fail.
fix
Ensure custom agents have keepAlive: true, or omit them to let the library add default agents.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: client.get is not a function
NtlmClient returns a function, not a full axios instance with .get/.post methods.
fix
Use client({ url, method: 'get' }) or client.get if you created the client with an Axios config (as in the second example).
Cannot read property 'request' of undefined
Missing or incorrect axios peer dependency.
fix
Install axios: npm install axios@>=0.21.0
Error: NTLM handshake failed - invalid credentials
Username, password, or domain is incorrect; or the target server does not support NTLM.
fix
Verify credentials and ensure the server uses Windows Authentication (NTLM).
Upgrade
Version history
1.4.2latest on npm
Audit
Dependencies
axiosrequiredpeer dependency; requires axios >=0.21.0 for interceptor functionality
Agent activity
21 hits · last 30 days
node
20
Resources
axios-nlm — npm install axios-nlm · libregistry