admin管理员组

文章数量:1196992

I have a project that I am using yarn for. I've installed all my packages using yarn, I run yarn dev and so on. Now I'm following a tutorial that requires me to use npx to set up a package. - I'm wondering if I can just go ahead with this or if I will end up mixing things up here, as npx, as far as I know, is related to npm ?

I have a project that I am using yarn for. I've installed all my packages using yarn, I run yarn dev and so on. Now I'm following a tutorial that requires me to use npx to set up a package. - I'm wondering if I can just go ahead with this or if I will end up mixing things up here, as npx, as far as I know, is related to npm ?

Share Improve this question asked Sep 27, 2021 at 11:23 antonwilhelmantonwilhelm 7,4835 gold badges33 silver badges65 bronze badges 4
  • 1 npx does nothing more than invoking a script on a npm repository (which yarn also uses) without actually installing it (globally). It can be used interchangeable with yarn. – nbokmans Commented Sep 27, 2021 at 11:28
  • 1 Also you can use yarn instead of npx. – Cenk Çetinkaya Commented Sep 27, 2021 at 11:28
  • 1 Thanks a lot! instead of but also with it ? as in: can I today install everything with yarn, tomorrow use an npx command and then next week use yarn add xxx again? – antonwilhelm Commented Sep 27, 2021 at 11:30
  • I was just wondering if I should do this. I just used npx for npx eslint init. It created a package-lock.json (along with other configs and added dependencies), then I deleted the package-lock.json and ran yarn after to properly install. Seems like it worked without any problems. – user3773048 Commented Sep 28, 2021 at 19:34
Add a comment  | 

1 Answer 1

Reset to default 24

Yes. npx will run the executable from your node_modules directory if it is installed there. If it is not, it will install the executable into a different location. It will not interfere with yarn operations.

With Yarn 2, you can also use dlx. For example:

yarn dlx create-react-app ./my-app

See https://yarnpkg.com/cli/dlx for information and options.

本文标签: javascriptCan I use NPX with yarnStack Overflow