remark-lint "Could not find module" plugin failure in CI
remark loads the presets and plugins named in .remarkrc from node_modules. If a preset like remark-preset-lint-recommended is not installed, remark fails to resolve it before linting any Markdown.
What this error means
remark exits with "Error: Could not find module remark-preset-lint-recommended" or "Cannot find package", even though .remarkrc lists it.
remark-lint
docs/guide.md
1:1 error Error: Cannot find package 'remark-preset-lint-recommended'
imported from .remarkrc.js
x 1 errorCommon causes
The preset or plugin is not a dependency
The .remarkrc references a package that is not in package.json, so CI never installs it.
Dependencies were not installed before remark ran
The workflow ran remark before npm ci, or in a directory without the installed node_modules.
How to fix it
Install the presets and run after npm ci
- Add remark and every referenced preset/plugin to devDependencies.
- Run
npm cibefore the remark step. - Invoke remark with
npxso node_modules/.bin is on PATH.
.github/workflows/docs.yml
- run: npm ci
- run: npx remark docs/ --frailDeclare plugins in a resolvable .remarkrc
List presets by installed package name so remark resolves them from node_modules.
.remarkrc
{
"plugins": [
"remark-preset-lint-recommended",
"remark-lint-list-item-indent"
]
}How to prevent it
- Keep every referenced remark preset/plugin in devDependencies.
- Run
npm cibefore remark and call it vianpx. - Use
--frailso lint warnings fail CI deterministically.
Related guides
markdownlint-cli2 config not found or not applied in CIFix markdownlint-cli2 in CI where the config is not found or not applied - rules fire that your local run doe…
markdownlint "command not found" in CIFix "markdownlint: command not found" in CI - the runner never installed markdownlint or markdownlint-cli2, s…
doctoc / markdown-toc table of contents out of date in CIFix a docs job that fails because the generated table of contents is stale in CI - doctoc or markdown-toc reg…