{"id":20353,"library":"prettier-plugin-ejs","title":"Prettier Plugin for EJS","description":"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.","status":"active","version":"1.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/ecmel/prettier-plugin-ejs","tags":["javascript","prettier","plugin","ejs","html"],"install":[{"cmd":"npm install prettier-plugin-ejs","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-plugin-ejs","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-plugin-ejs","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for plugin functionality","package":"prettier","optional":false}],"imports":[{"note":"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.","wrong":"// Trying to import as an ESM module: import 'prettier-plugin-ejs'","symbol":"plugin","correct":"// Prettier v3 CLI: prettier --plugin=prettier-plugin-ejs --write ."},{"note":"For Prettier v3, you must explicitly add the plugin to your config or CLI. For v2, it is auto-loaded.","wrong":"// Invalid: plugins: ['prettier-plugin-ejs'] in .prettierrc.json (v3 requires string? actually works)","symbol":"prettier-plugin-ejs","correct":"module.exports = {\n  plugins: ['prettier-plugin-ejs']\n}"},{"note":"If using Prettier's API programmatically, require the plugin and pass to plugins array.","wrong":"// Using dynamic import without proper setup: import('prettier-plugin-ejs')","symbol":"require('prettier-plugin-ejs')","correct":"const prettier = require('prettier'); const plugin = require('prettier-plugin-ejs');"}],"quickstart":{"code":"npm install --save-dev prettier prettier-plugin-ejs\n# Prettier v3 usage:\nprettier --plugin=prettier-plugin-ejs --write \"**/*.html\"\n# Or create .prettierrc:\necho '{\"plugins\": [\"prettier-plugin-ejs\"]}' > .prettierrc","lang":"javascript","description":"Installs the plugin and formats all HTML files with EJS tags using Prettier v3."},"warnings":[{"fix":"Avoid using > inside EJS delimiters; refactor to use alternatives like `gt;` or separate logic.","message":"EJS tags containing the greater-than symbol (`>`) are ignored and not formatted.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use `--plugin=prettier-plugin-ejs` or add to plugins array in config.","message":"Prettier v3 requires explicit plugin loading; it is not auto-loaded like in v2.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update to v1.0.0 and ensure Prettier >=2.0. Follow migration notes in changelog.","message":"Upgrading from v0.x to v1.0.0 may require configuration changes due to breaking changes in plugin API.","severity":"deprecated","affected_versions":"0.x"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install --save-dev prettier-plugin-ejs` and ensure node_modules is present.","cause":"Plugin not installed or Prettier cannot resolve it.","error":"Cannot find module 'prettier-plugin-ejs'"},{"fix":"Update to prettier-plugin-ejs@1.0.0+ for Prettier v2/v3 support.","cause":"Using an incompatible version of Prettier (v3 vs v2 plugin API).","error":"The plugin \"prettier-plugin-ejs\" did not export a factory function."},{"fix":"Escape `>` as `&gt;` or reformat to avoid it inside EJS expressions.","cause":"The plugin does not handle EJS tags containing `>` because it marks them as comments.","error":"Error: Cannot parse inline EJS tags with `>`"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}