{"id":16277,"library":"wordnet-db","title":"WordNet Database Files for Node.js","description":"wordnet-db is a specialized Node.js package designed to provide the complete database files for WordNet 3.1 directly within an npm installation. Currently at version 3.1.14, it offers a robust solution for developers requiring offline access to the Princeton WordNet lexical database, which is particularly useful for natural language processing libraries like `wordpos` and `natural`. The package differentiates itself by pre-bundling the entire 34 MB uncompressed WordNet dictionary, eliminating the need for on-demand downloads or complex setup scripts during application runtime. Its release cadence is primarily reactive, addressing compatibility with newer Node.js versions, fixing installation-related issues, or updating to newer WordNet database versions (though it has been stable on WordNet 3.1 for a while). This ensures that applications can deploy with a guaranteed, self-contained WordNet data source, even in environments with restricted internet access.","status":"active","version":"3.1.14","language":"javascript","source_language":"en","source_url":"git://github.com/moos/wordnet-db","tags":["javascript","WordNet","wordpos","natural","pos"],"install":[{"cmd":"npm install wordnet-db","lang":"bash","label":"npm"},{"cmd":"yarn add wordnet-db","lang":"bash","label":"yarn"},{"cmd":"pnpm add wordnet-db","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only. ES modules import syntax will fail.","wrong":"import wordnetDb from 'wordnet-db';","symbol":"wordnetDb","correct":"const wordnetDb = require('wordnet-db');"},{"note":"Properties like `path`, `files`, `version`, and `libVersion` are accessed directly from the default export object.","wrong":"import { path as dbPath } from 'wordnet-db';","symbol":"dbPath","correct":"const dbPath = require('wordnet-db').path;"},{"note":"While object destructuring works with `require`, direct property access is the idiomatic way shown in documentation for this package.","wrong":"const { version: dbVersion } = require('wordnet-db');","symbol":"dbVersion","correct":"const dbVersion = require('wordnet-db').version;"}],"quickstart":{"code":"const wordnetDb = require('wordnet-db');\nconst fs = require('fs');\nconst path = require('path');\n\nconsole.log('--- WordNet DB Information ---');\nconsole.log(`Package version: ${wordnetDb.libVersion}`);\nconsole.log(`WordNet data version: ${wordnetDb.version}`);\nconsole.log(`Database files path: ${wordnetDb.path}`);\nconsole.log(`Number of files: ${wordnetDb.files.length}`);\n\n// Verify a common WordNet data file exists\nconst exampleFile = 'data.noun';\nconst fullPath = path.join(wordnetDb.path, exampleFile);\n\nconsole.log(`\\nChecking for existence of \"${exampleFile}\" at \"${fullPath}\"...`);\n\ntry {\n  fs.accessSync(fullPath, fs.constants.F_OK);\n  console.log(`SUCCESS: \"${exampleFile}\" found. WordNet database seems correctly installed.`);\n\n  // Optionally, read a few lines to confirm content\n  const content = fs.readFileSync(fullPath, 'utf8');\n  console.log(`First 3 lines of ${exampleFile}:\\n${content.split('\\n').slice(0, 3).join('\\n')}`);\n\n} catch (err) {\n  console.error(`ERROR: \"${exampleFile}\" not found or inaccessible. Installation may be incomplete or corrupted.`);\n  console.error(err.message);\n}","lang":"javascript","description":"This script demonstrates how to import `wordnet-db`, access its properties (like path and versions), and verify the presence and content of a sample WordNet data file."},"warnings":[{"fix":"Update `package.json` dependencies and all `require()` statements from `WNdb` to `wordnet-db`.","message":"The package name was changed from `WNdb` to `wordnet-db` to comply with npm naming rules. While old links might still resolve, all new installations and references should use `wordnet-db`.","severity":"breaking","affected_versions":">=3.1.2"},{"fix":"Ensure your Node.js environment is version 0.6.0 or higher. For modern applications, use the latest LTS Node.js release.","message":"Older Node.js versions (specifically <0.6) are not supported due to the package's internal reliance on Node.js's built-in `zlib` module for handling compressed data.","severity":"gotcha","affected_versions":"<3.0.1"},{"fix":"No direct fix needed for newer versions, as it simplifies installation. If you encounter `tar` related errors on older versions, upgrade to `wordnet-db@^3.1.13`.","message":"The method of database file distribution and installation changed significantly. In versions prior to `3.1.12`, a `tar` dependency was used. From `3.1.12` onwards, `tar` was removed, and from `3.1.13`, the `.tar.gz` archive was removed from the npm package, with dictionary files included directly. This affects installation logic and potential `tar` related issues.","severity":"breaking","affected_versions":">=3.1.12"},{"fix":"Before cloning the repository on Windows for version 3.0.0, execute `git config core.autocrlf false` to prevent CRLF conversions that can damage data files.","message":"On Windows systems, if you are working with WordNet 3.0.0 directly from a git clone, automatic CRLF (Carriage Return Line Feed) conversion can corrupt the data files. This was relevant when text dict files were included uncompressed.","severity":"gotcha","affected_versions":"3.0.0"},{"fix":"If experiencing installation issues with `npm@5` on older versions, upgrade to `wordnet-db@^3.1.6` or later.","message":"Installation issues were reported with `npm@5` due to postinstall script order. Version `3.1.6` introduced a fix by including `dict` files directly and disabling the postinstall script.","severity":"gotcha","affected_versions":"~3.1.4 - 3.1.5"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Upgrade to `wordnet-db@^3.1.13` to use the version where `tar` is no longer a dependency and dictionary files are directly bundled.","cause":"An older version of `wordnet-db` was installed which had `tar` as a runtime dependency, and `tar` failed to install correctly.","error":"Error: Cannot find module 'tar'"},{"fix":"For version `3.0.0` specifically, ensure `git config core.autocrlf false` is set before cloning the repository. For later versions (3.1.x), this issue is largely mitigated by how files are packaged.","cause":"When using `wordnet-db@3.0.0` or cloning the repository directly, Git's `core.autocrlf` setting on Windows converted line endings in the plain text data files, corrupting them.","error":"WordNet data files appear corrupted or have incorrect line endings on Windows."}],"ecosystem":"npm"}