admin管理员组

文章数量:1207126

I'm trying to understand how this Node.js command works:

npx @11ty/eleventy

From what I understood, it looks like npx first goes into node_modules/@11ty/eleventy and finds the package.json file. More specifically, it looks for this part:

"bin": {
  "eleventy": "cmd.cjs"
}

Now, I tried changing the key from "eleventy" to "hey" and now when running npx @11ty/eleventy I got this error:

sh: hey: command not found

"sh" probably indicates this comes from the shell, which probably means that "npx" tried to find this executable inside node_modules/.bin, but couldn't find it.

How did "npx" decide to execute hey in the first place? I don't quite understand how the matching algorithm works when it comes to npx and scoped packages. Tried looking it up everywhere but couldn't find any documentation on this.

本文标签: nodejsnpx and scoped packagesStack Overflow