Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
set
✓ import { set } from 'libnpmorg'
✗ const { set } = require('libnpmorg')
The README examples show `require`, but ESM `import` is the modern approach. `libnpmorg` exports named functions.
ls
✓ import { ls } from 'libnpmorg'
✗ import org from 'libnpmorg'; org.ls(...)
The library exports individual functions, not a default object. Destructuring is required.
ls.stream
✓ import { ls } from 'libnpmorg'; const stream = ls.stream(...)
✗ import { lsStream } from 'libnpmorg'
`stream` is a property of the `ls` function, not a top-level export.
This example demonstrates how to list, add, and remove members from an npm organization using `libnpmorg` functions, including handling authentication.
import { ls, set, rm } from 'libnpmorg';
const ORG_NAME = 'my-test-org'; // Replace with a real org name or test org
const USER_NAME = 'testuser'; // Replace with a real username
const AUTH_TOKEN = process.env.NPM_TOKEN ?? ''; // Ensure you have an npm automation token
async function manageOrgMembership() {
if (!AUTH_TOKEN) {
console.error('NPM_TOKEN environment variable is not set. Cannot perform authenticated operations.');
return;
}
try {
console.log(`Listing members of ${ORG_NAME}...`);
const roster = await ls(ORG_NAME, { token: AUTH_TOKEN });
console.log('Current Roster:', roster);
console.log(`Adding ${USER_NAME} to ${ORG_NAME} as developer...`);
const newMembership = await set(ORG_NAME, USER_NAME, 'developer', { token: AUTH_TOKEN });
console.log('New Membership:', newMembership);
console.log(`Roster after adding ${USER_NAME}:`);
console.log(await ls(ORG_NAME, { token: AUTH_TOKEN }));
console.log(`Removing ${USER_NAME} from ${ORG_NAME}...`);
await rm(ORG_NAME, USER_NAME, { token: AUTH_TOKEN });
console.log(`${USER_NAME} removed.`);
console.log(`Roster after removing ${USER_NAME}:`);
console.log(await ls(ORG_NAME, { token: AUTH_TOKEN }));
} catch (error) {
console.error('An error occurred:', error.message);
if (error.code === 'EOTP') {
console.error('This operation requires an OTP token. Please retry with `{otp: <your-2fa-token>}`.');
}
}
}
manageOrgMembership();
Errors
Common errors & fixes
Error: ENEEDAUTH npm-registry-fetch No auth for the current registry and scope.
Attempting to perform an authenticated operation without providing a valid authentication token or without being logged in via npm CLI.
fixEnsure `opts.token` is provided with a valid npm automation token, or run `npm login` in your environment.
Error: EOTP This command requires a one-time password.
An operation (e.g., `set` or `rm`) was attempted on an organization or user that requires 2FA, but no OTP was supplied.
fixRetry the operation, including `{ otp: 'your_6_digit_otp' }` in the options object. TypeError: org.set is not a function
Attempting to call `org.set` (or `org.ls`, `org.rm`) after importing `libnpmorg` as a default import instead of using named imports/destructuring.
fixChange `import org from 'libnpmorg'` to `import { set, ls, rm } from 'libnpmorg'`. Audit
Dependencies
npm-registry-fetchrequiredUsed internally for all network requests to the npm registry.