{"id":16697,"library":"userito","title":"Userito","description":"Userito is a Node.js library designed for managing user data, offering persistence options via either a local JSON file or a MongoDB database. The current stable version is 5.0.0, released in 2022, which introduced support for Node.js 16 and dropped compatibility with older Node.js versions. While there isn't a strict release cadence, new major versions typically align with Node.js End-of-Life (EOL) cycles, dropping support for older runtimes, and incorporating dependency updates like Mongoose. Its primary differentiator is the flexibility to switch between simple file-based storage, suitable for development or small applications, and a robust MongoDB backend for more scalable solutions, all through a unified, function-based API. It provides core CRUD operations for user management.","status":"active","version":"5.0.0","language":"javascript","source_language":"en","source_url":"git://github.com/coderaiser/node-userito","tags":["javascript","users","rest","mongodb"],"install":[{"cmd":"npm install userito","lang":"bash","label":"npm"},{"cmd":"yarn add userito","lang":"bash","label":"yarn"},{"cmd":"pnpm add userito","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for MongoDB database storage ('type: db' option).","package":"mongoose","optional":false}],"imports":[{"note":"The 'userito' package exports a factory function as its default. You must invoke it immediately with options to get an operational instance.","wrong":"const useritoInstance = require('userito'); // Missing immediate invocation","symbol":"userito (factory function)","correct":"const useritoFactory = require('userito');\nconst useritoInstance = useritoFactory({ type: 'file' });"},{"note":"This is the idiomatic CommonJS way to initialize Userito directly at the point of import.","wrong":"const { useritoFile } = require('userito'); // Not a named export","symbol":"userito (chained initialization)","correct":"const useritoFile = require('userito')({ type: 'file' });"},{"note":"For ESM environments, import the default factory function and then call it with your configuration options. Requires Node.js 16+.","wrong":"import { useritoFile } from 'userito'; // Not a named export, default export is a function","symbol":"userito (ESM import)","correct":"import useritoFactory from 'userito';\nconst useritoFile = useritoFactory({ type: 'file' });"}],"quickstart":{"code":"import useritoFactory from 'userito';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nasync function main() {\n  const useritoFile = useritoFactory({\n    type: 'file',\n    path: path.join(__dirname, 'users.json') // Use a specific path for the quickstart\n  });\n\n  // Create a new user\n  await new Promise(resolve => {\n    useritoFile.create({ username: 'testuser', password: 'securepassword' }, (error, msg) => {\n      if (error) console.error('Error creating user:', error);\n      else console.log('User created:', msg);\n      resolve();\n    });\n  });\n\n  // Get all users\n  await new Promise(resolve => {\n    useritoFile.all((error, users) => {\n      if (error) console.error('Error getting all users:', error);\n      else console.log('All users:', users);\n      resolve();\n    });\n  });\n\n  // Get a specific user\n  await new Promise(resolve => {\n    useritoFile.get('testuser', (error, user) => {\n      if (error) console.error('Error getting user:', error);\n      else console.log('Specific user:', user);\n      resolve();\n    });\n  });\n\n  // Remove the user\n  await new Promise(resolve => {\n    useritoFile.remove('testuser', (error, info) => {\n      if (error) console.error('Error removing user:', error);\n      else console.log('User removed:', info);\n      resolve();\n    });\n  });\n}\n\nmain().catch(console.error);","lang":"typescript","description":"This quickstart demonstrates how to initialize Userito with file-based storage and perform basic CRUD operations (create, get all, get one, remove) for users."},"warnings":[{"fix":"Upgrade your Node.js runtime to version 16 or newer before upgrading to Userito v5.0.0.","message":"Userito v5.0.0 drops support for Node.js versions older than 16. Applications running on Node.js 14 or earlier will break upon upgrade.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Upgrade your Node.js runtime to version 14 or newer. For v5.x, Node.js 16+ is required.","message":"Userito v4.0.0 dropped support for Node.js versions older than 14. This was a significant breaking change for users on older runtimes.","severity":"breaking","affected_versions":">=4.0.0 <5.0.0"},{"fix":"Ensure your Node.js runtime is version 10 or newer. For v4.x, Node.js 14+ is needed, and for v5.x, Node.js 16+ is required.","message":"Userito v3.0.0 dropped support for Node.js versions 8 and older, requiring Node.js 10 or newer. This introduced potential breaking changes for legacy applications.","severity":"breaking","affected_versions":">=3.0.0 <4.0.0"},{"fix":"Verify your MongoDB connection string is correctly formatted. Ensure any provided `schema` object matches the structure of your user data in MongoDB. Consult Mongoose documentation for connection string options compatible with `mongoose` v6.5.0 (used in userito v5.0.0).","message":"The `db` option for MongoDB initialization requires a Mongoose-compatible connection string and optionally a schema definition. Incorrect connection strings or missing schema fields can lead to database connection errors or unexpected data behavior.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Review the Mongoose v6.x migration guide if you encounter issues, especially regarding connection options (like `useNewUrlParser`, `useUnifiedTopology`, etc.) which are now default or removed. Ensure your MongoDB instance is compatible.","message":"Version 5.0.0 updated the underlying Mongoose dependency to `v6.5.0`. This could introduce breaking changes or require adjustments to Mongoose-specific options if your application directly interacted with Mongoose instances or relied on deprecated features from older Mongoose versions.","severity":"breaking","affected_versions":">=5.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Initialize Userito by calling the imported function with configuration: `const useritoInstance = require('userito')({ type: 'file' });` or `import useritoFactory from 'userito'; const useritoInstance = useritoFactory({ type: 'file' });`","cause":"The 'userito' package exports a factory function that must be invoked with options to return an operational instance, not an object with methods directly.","error":"TypeError: userito.all is not a function"},{"fix":"Userito v5.0.0 uses Mongoose v6.5.0. Remove deprecated options like `useNewUrlParser`, `useUnifiedTopology`, `useFindAndModify`, and `useCreateIndex` from your MongoDB connection string or `db` options, as they are no longer necessary or supported in Mongoose 6+.","cause":"This error typically occurs when using Mongoose v6.x (or newer) with old connection options that are no longer supported or are defaults.","error":"MongoParseError: option useUnifiedTopology is not supported"},{"fix":"Install 'userito' locally in your project: `npm i userito`. If it's already installed, check your `node_modules` and module resolution paths.","cause":"The 'userito' package was likely installed globally (`npm i userito -g`) but not locally in your project, or the module resolution path is incorrect.","error":"Error: Cannot find module 'userito'"},{"fix":"If 'userito' is indeed an ESM-only package (check its `package.json` `type` field or main entry point), ensure your project is configured for ESM (e.g., `\"type\": \"module\"` in your `package.json`) and use `import useritoFactory from 'userito';` instead of `require()`.","cause":"Attempting to `require()` an ESM-only package in a CommonJS context, or `userito` is incorrectly configured as ESM-only for your environment.","error":"ERR_REQUIRE_ESM: require() of ES Module .../node_modules/userito/index.mjs not supported."}],"ecosystem":"npm"}