Registry / web-framework / prettier-plugin-ejs

prettier-plugin-ejs

JSON →
library1.0.3jsnpmunverified

A Prettier plugin that formats EJS (Embedded JavaScript) templates within HTML files. Current stable version 1.0.3 supports Prettier 2.x and 3.x. It works by marking EJS tags as comments and relying on Prettier's built-in HTML parser, so it does not have its own parser — this keeps it lightweight but means EJS tags containing `>` are ignored. Compared to alternatives like prettier-plugin-ejs-by-ecmel, this is the most popular and maintained option. Release cadence is irregular, with infrequent updates; the plugin has been stable for years without major changes.

npm install prettier-plugin-ejs
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-EJ
P
prettier-plugin-ejs
web-frameworkjavascriptv1.0.3
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.

plugin
// Prettier v3 CLI: prettier --plugin=prettier-plugin-ejs --write .
// Trying to import as an ESM module: import 'prettier-plugin-ejs'
This is a Prettier plugin, not a JavaScript module. It is loaded by Prettier either automatically (v2) or via CLI/ config (v3). Do not import in source code.
prettier-plugin-ejs
module.exports = { plugins: ['prettier-plugin-ejs'] }
// Invalid: plugins: ['prettier-plugin-ejs'] in .prettierrc.json (v3 requires string? actually works)
For Prettier v3, you must explicitly add the plugin to your config or CLI. For v2, it is auto-loaded.
require('prettier-plugin-ejs')
const prettier = require('prettier'); const plugin = require('prettier-plugin-ejs');
// Using dynamic import without proper setup: import('prettier-plugin-ejs')
If using Prettier's API programmatically, require the plugin and pass to plugins array.

Installs the plugin and formats all HTML files with EJS tags using Prettier v3.

npm install --save-dev prettier prettier-plugin-ejs # Prettier v3 usage: prettier --plugin=prettier-plugin-ejs --write "**/*.html" # Or create .prettierrc: echo '{"plugins": ["prettier-plugin-ejs"]}' > .prettierrc
Debug
Known issues
gotchaEJS tags containing the greater-than symbol (`>`) are ignored and not formatted.
fix
Avoid using > inside EJS delimiters; refactor to use alternatives like `gt;` or separate logic.
affects: >=0.0.0
gotchaPrettier v3 requires explicit plugin loading; it is not auto-loaded like in v2.
fix
Use `--plugin=prettier-plugin-ejs` or add to plugins array in config.
affects: >=1.0.0
deprecatedUpgrading from v0.x to v1.0.0 may require configuration changes due to breaking changes in plugin API.
fix
Update to v1.0.0 and ensure Prettier >=2.0. Follow migration notes in changelog.
affects: 0.x
Errors
Common errors & fixes
Cannot find module 'prettier-plugin-ejs'
Plugin not installed or Prettier cannot resolve it.
fix
Run `npm install --save-dev prettier-plugin-ejs` and ensure node_modules is present.
The plugin "prettier-plugin-ejs" did not export a factory function.
Using an incompatible version of Prettier (v3 vs v2 plugin API).
fix
Update to prettier-plugin-ejs@1.0.0+ for Prettier v2/v3 support.
Error: Cannot parse inline EJS tags with `>`
The plugin does not handle EJS tags containing `>` because it marks them as comments.
fix
Escape `>` as `>` or reformat to avoid it inside EJS expressions.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
prettierrequiredPeer dependency required for plugin functionality
Agent activity
4 hits · last 30 days
node
4
Resources
prettier-plugin-ejs — npm install prettier-plugin-ejs · libregistry