Registry / web-framework / sails-build-dictionary

sails-build-dictionary

JSON →
library0.10.1jsnpmunverified

sails-build-dictionary is a utility package designed to recursively build a dictionary (plain JavaScript object) of modules from specified directories, leveraging the `include-all` library. It was a foundational component for older versions of the Sails.js framework (prior to v1.0), primarily used for automatically loading application components like models, controllers, and services by convention into a structured object accessible within the Sails application instance. The package's latest version is 0.10.1, with its last publication dating back 12 years (as of March 2014). Since Sails v1.0, this module has been officially deprecated, with the recommendation that developers directly use `include-all@1.x.x` for similar functionality. Consequently, `sails-build-dictionary` is no longer actively maintained and does not receive updates, including security patches or compatibility adjustments for newer Node.js versions.

npm install sails-build-dictionary
INSTALL
IMPORT
SIG · SAILS-BUILD-DICTIO
S
sails-build-dictionary
web-frameworkjavascriptv0.10.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

buildDictionary
const buildDictionary = require('sails-build-dictionary');
import buildDictionary from 'sails-build-dictionary'; import { buildDictionary } from 'sails-build-dictionary';
This package is CommonJS-only, as it was last published 12 years ago (version 0.10.1). ESM imports will fail.

This example demonstrates how to use `sails-build-dictionary` to recursively load JavaScript modules from a simulated Sails.js `api` directory structure into a nested dictionary object. It creates dummy model and controller files, then aggregates them into a single object.

const path = require('path'); const buildDictionary = require('sails-build-dictionary'); const fs = require('fs'); // Create a dummy directory structure for demonstration const appDir = path.join(__dirname, 'temp-app'); const modelsDir = path.join(appDir, 'api', 'models'); const controllersDir = path.join(appDir, 'api', 'controllers'); fs.mkdirSync(modelsDir, { recursive: true }); fs.mkdirSync(controllersDir, { recursive: true }); fs.writeFileSync(path.join(modelsDir, 'User.js'), 'module.exports = { attributes: { name: "string" } };'); fs.writeFileSync(path.join(modelsDir, 'Product.js'), 'module.exports = { attributes: { item: "string" } };'); fs.writeFileSync(path.join(controllersDir, 'AuthController.js'), 'module.exports = { login: function() {} };'); console.log('Building dictionary from temp-app/api/...'); buildDictionary.aggregate({ dirname: path.join(appDir, 'api') }, function (err, modules) { if (err) { console.error('Error building dictionary:', err); return; } console.log('Successfully built dictionary:'); console.log(JSON.stringify(modules, null, 2)); // Expected output structure: // { // "models": { // "User": { /* ... User module content ... */ }, // "Product": { /* ... Product module content ... */ } // }, // "controllers": { // "Auth": { /* ... AuthController module content ... */ } // } // } // Clean up dummy directories fs.rmSync(appDir, { recursive: true, force: true }); });
Debug
Known issues
breakingThe `sails-build-dictionary` package is officially DEPRECATED since Sails v1.0. Its functionality is no longer integrated into the Sails.js framework, and direct usage within a modern Sails application is discouraged. Users upgrading to Sails v1.0 and beyond should use `include-all@1.x.x` directly for similar module loading needs.
fix
For new projects or updated Sails applications (v1.0+), bypass `sails-build-dictionary` and use `require('include-all')` directly to load modules. Consult the `include-all` documentation for its API.
affects: >=1.0.0
gotchaThis package is an older CommonJS-only module (last published 12 years ago). Attempting to use ES module `import` syntax will result in a runtime error.
fix
Always use Node.js `require()` syntax to import `sails-build-dictionary`. Ensure your project environment is configured for CommonJS if you intend to use this legacy package.
affects: >=0.1.0
gotchaAs a deprecated package with no updates for over a decade, `sails-build-dictionary` receives no active maintenance, including security patches or compatibility updates for newer Node.js versions or file system APIs. Using it in production environments is highly risky due to potential vulnerabilities or runtime instability.
fix
Migrate away from `sails-build-dictionary` to `include-all` or a modern, actively maintained module loader that supports your project's Node.js version and module system (CommonJS/ESM).
affects: >=0.10.1
Errors
Common errors & fixes
Error: Cannot find module 'sails-build-dictionary'
This error typically occurs if the package is not installed (run `npm install sails-build-dictionary`) or if you are attempting to use ES module `import` syntax in a CommonJS-only environment, which leads to module resolution failure.
fix
Ensure the package is installed: `npm install sails-build-dictionary`. If using ES modules, remember that `sails-build-dictionary` is CommonJS-only; use `const buildDictionary = require('sails-build-dictionary');`.
TypeError: buildDictionary.aggregate is not a function
The main export of `sails-build-dictionary` (or `include-all` which it wraps) is usually a function or an object with methods like `aggregate`. This error indicates that the imported variable is not what's expected or a method is being called incorrectly.
fix
Double-check the usage against the quickstart example. The primary method for building dictionaries is `buildDictionary.aggregate()`. Ensure your `require()` statement correctly captures the exported object and you are calling the method on it.
Upgrade
Version history
0.10.1latest on npm
Audit
Dependencies
include-allrequiredCore functionality for recursively loading modules from directories. Users are advised to use `include-all` directly since Sails v1.0.
Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
2
Resources
sails-build-dictionary — npm install sails-build-dictionary · libregistry