`eslint-plugin-node-import` is an ESLint plugin designed to enforce the use of the `node:` protocol prefix for built-in Node.js modules, a best practice introduced in Node.js v14 to disambiguate bare module specifiers from npm packages. The current stable version is v1.2.0, which notably introduced TypeScript typings and improved support for ESLint's new flat configuration system (`eslint.config.js`). This plugin offers a singular, focused rule, `prefer-node-protocol`, providing a dedicated solution for this specific coding standard, unlike broader linting plugins that might bundle this rule among many others. It maintains an active development cadence, with several releases over the past year addressing compatibility with newer Node.js versions (up to v23.5.0+) and adding features like flat config support.
npm install eslint-plugin-node-importVerified import paths — ran on the pinned version, not inferred.
Demonstrates installation and configuration using ESLint's flat config (`eslint.config.js`), extending the recommended preset and manually enabling the `prefer-node-protocol` rule.
For `eslint.config.js`, always use `const plugin = require('eslint-plugin-node-import');`. For `.eslintrc.js`, ensure it's a CommonJS file and configure via `plugins` and `extends` arrays.Use ESLint's `overrides` configuration to apply the `node-import/prefer-node-protocol` rule only to files intended for Node.js environments, or disable it for browser-specific code.
Review your ESLint configuration for duplicate rules. Disable `node-import/prefer-node-protocol` if `eslint-plugin-unicorn`'s equivalent rule is already active and sufficient, or vice-versa.
Ensure `eslint-plugin-node-import` is installed (`npm install eslint-plugin-node-import --save-dev`) and added to the `plugins` array in your ESLint configuration (e.g., `plugins: ["node-import"]` for legacy config or `plugins: {"node-import": nodeImport}` for flat config).Run `npm install eslint-plugin-node-import --save-dev` to install the package. Verify that ESLint is being run from a directory where `node_modules` is accessible.