11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
https://www.11ty.dev/
MIT License
16.97k stars 491 forks source link

ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL when running Eleventy with PNPM #2142

Closed ghost closed 3 months ago

ghost commented 2 years ago

Description of the Bug

I'm following the Getting Started guide. After installation of Eleventy and creation of some basic files (index.html and README.md) I tried to execute Eleventy, but got the following error message:

ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Command failed with ENOENT: @11ty/eleventy
spawn @11ty/eleventy ENOENT

This happens only when using pnpm and doesn't happen when using npx.

To Reproduce

Steps to reproduce the behaviour:

  1. Install Eleventy: pnpm add -D @11ty/eleventy,
  2. Create index.html and README.md files with basic contents,
  3. Run pnpm @11ty/eleventy or pnpm exec @11ty/eleventy and get the error message mentioned above,
  4. Run npx @11ty/eleventy to ensure that it doesn't happen with npx.

Expected Behavior

Writing _site/README/index.html from ./README.md.
Writing _site/index.html from ./index.html.
Wrote 2 files in 0.07 seconds (v0.12.1)

Environment

serixscorpio commented 2 years ago

For now I workaround using pnpm dlx @11ty/eleventy.

uncenter commented 3 months ago

I think this really just boils down to how the current documentation suggests running Eleventy with npx @11ty/eleventy, which is actually quite confusing. npx for the most part is used to pull down and execute packages from the registry as a one time deal (not installed in a directory or anything). npx does work however to use local binaries when possible, which is why this method works to run the locally installed version of Eleventy. However, pnpm/pnpm exec are for executing "a shell command in scope of a project", and there actually isn't a binary called @11ty/eleventy - the actual name is just eleventy, and pnpm tells you this in the same error as originally reported (see the last line of below):

 ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Command "@11ty/eleventy" not found

Did you mean "pnpm exec eleventy"?

The documentation should probably be updated to recommend eleventy over npx @11ty/eleventy.

zachleat commented 3 months ago

As part of #2876 I did verify the relevant commands here and confirmed they are working. The docs have been updated too as noted here https://github.com/11ty/eleventy/issues/2876#issuecomment-2207189707

Thank you (and appreciate your help here @uncenter!)