'Is there any Yarn equivalent of npx preact create?

I am trying to run the preact create command using Yarn. It's simple to run preact create ..... ..... or npx preact create ... ..... It works fine and both of the commands use npm. But I am trying to run the command using Yarn. I have tried the following commands but nothing works. The error says "couldn't find a package.json file in path".

yarn preact create .... ....

yarn dlx preact create .... ....

yarn preact-cli create .... ....

yarn dlx preact-cli create .... ....

So, what should I do to run the command using Yarn. One alternative maybe is running the command using npm and then running yarn install and then running npm uninstall. But what's the actual way?



Solution 1:[1]

There is no Yarn equivalent for npx. The Yarn team thought npx was enough.

That being said, we support creating a new Preact CLI project with Yarn through the --yarn flag.

npx preact-cli create ... --yarn

https://github.com/preactjs/preact-cli#cli-options

Please do note that when using Preact CLI via NPX, you do need to use preact-cli. npx preact gives you the Preact library.

Solution 2:[2]

In general, as of 2021, there is no equivalent for npx

Feature was requested in yarn, but went not really solved https://github.com/yarnpkg/yarn/issues/3937

So package developers need to think for both npm and yarn users.

Solution 3:[3]

For a TL;DR answer from the thread mentioned above. You can find the following.

npx performs no operations which clash with people using other package managers [...] So you could say npx is ypx, unless you feel really strongly about cache-sharing, which is a pretty thing. For the probable reasoning of not creating a ypx specific command

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Paul Verest
Solution 3 Emile Bergeron