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.
generatorDefinition
✓ const generatorDefinition = require('sails-generate-api');
This package is a CommonJS module from the 0.x era. It exports an object defining the generator's behavior (e.g., targets, templates). Direct programmatic use is uncommon as it's primarily consumed by the Sails CLI system.
generate
✓ const { generate } = require('sails-generate-api'); // If an internal `generate` function were exposed
✗ import { generate } from 'sails-generate-api';
While a generator typically defines a 'generate' process, direct named export of such a function is not standard for this type of Sails 0.x generator module. This illustrates accessing a hypothetical internal method via CommonJS destructuring. ESM imports (`import`) are not supported.
ApiGeneratorModule
✓ // No direct application-level import for CLI generators.
// Configured via .sailsrc instead.
✗ import ApiGeneratorModule from 'sails-generate-api';
Sails generators are integrated by configuring the `.sailsrc` file to map a generator name (e.g., 'api') to its npm package. There is no typical 'default import' symbol for developers to use in their application code; the Sails CLI internally handles loading the generator module.
Demonstrates how to install, configure, and use the `sails-generate-api` generator to create new API files in a Sails 0.x project.
{
"generators": {
"modules": {
"api": "sails-generate-api"
}
}
}
// Save the above JSON to ./.sailsrc in your project directory
// or ~/.sailsrc for global use.
// Then, from your Sails project directory:
// $ npm install sails-generate-api
// $ sails generate api foobar
// This will create:
// - api/models/Foobar.js
// - api/controllers/FoobarController.js
Debug
Known issues
breakingThis package is designed for Sails.js versions 0.x and is incompatible with Sails.js v1.x and later. Major architectural changes, especially regarding the generator system, occurred in Sails v1.0.fixFor Sails v1.x+, use the built-in `sails generate api` command, or implement a custom generator following the v1.x generator conventions which are significantly different.
affects: >=1.0.0 of Sails.js
deprecatedThe `sails-generate-api` package has not been updated in 9 years and is considered abandoned. Its dependencies and internal logic may rely on outdated Node.js features or insecure third-party packages.fixAvoid using this package in new projects. For existing Sails 0.x projects, consider migrating to a newer Sails version or manually creating the required API files.
affects: >=0.10.1
gotchaThe `.sailsrc` configuration method for overriding or adding generators, as described in this package's README, is primarily for Sails 0.x. While `.sailsrc` still exists in Sails v1.x, the generator module structure and registration process have changed substantially.fixRefer to the official Sails.js v1.x documentation for current generator configuration and extension practices.
affects: >=0.10.1
Errors
Common errors & fixes
Error: sails-generate-api@0.10.1 requires a peer of sails@~0.10.0 but none was installed.
Attempting to install or use `sails-generate-api` with a newer version of Sails.js (e.g., v1.x+) or without any Sails.js installation, which is a peer dependency.
fixEnsure you are using Sails.js v0.x (specifically, within the ~0.10.0 range) with this generator. For example, `npm install sails@~0.10.0` globally or locally alongside the generator.
Error: sails-generate-api not found.
Error: Generator "api" could not be loaded from "sails-generate-api"
The `sails-generate-api` package was installed but the `.sailsrc` file was not correctly configured to point to it, or it was configured for a local installation but `sails generate` was run in a different directory.
fixVerify that `sails-generate-api` is installed and that your `.sailsrc` file (either local `./.sailsrc` or global `~/.sailsrc`) correctly maps `"api": "sails-generate-api"` within the `generators.modules` section. Ensure the `sails generate` command is executed from a directory where the `.sailsrc` configuration is active.
Audit
Dependencies
sailsrequiredRuntime dependency as it's a generator specifically for the Sails.js framework. Requires a pre-1.0 version of Sails.js.