Is there any Yarn equivalent of npx preact create?
Solution 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
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
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 saynpx
isypx
, unless you feel really strongly about cache-sharing, which is a pretty thing. For the probable reasoning of not creating aypx
specific command
Admin
Updated on June 15, 2022Comments
-
Admin almost 2 years
I am trying to run the
preact create
command using Yarn. It's simple to runpreact create ..... .....
ornpx 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?
-
Admin about 3 yearsThank you @rschristian for this useful answer. But the above line of code doesn't work. It still uses npm to install the dependencies. But thank you for informing me about the --yarn flag. I used it while running
preact create ...... ...... --yarn
and it works fine. Thoughpreact create
isn't an alternative to npx. -
rschristian about 3 yearsYou're saying
npx preact-cli create ... --yarn
doesn't install using yarn? Mind raising an issue in our tracker? I can't reproduce and I don't see how that could happen but it's clearly something we need to address. -
Admin about 3 yearsYeah, it's not working. Well, I'll open an issue in the github repo of preact.
-
rschristian about 3 yearsMake sure it's Preact-CLI, not Preact. Different things. But I'll take a look there.
-
Admin about 3 yearsHmm.. I tried running the command again before raising a issue in issue tracker. But now I see that it uses npm at first to install preact-cli (as I didn't install preact-cli using yarn). Then it uses to yarn to create the preact-app. So, it's normal I think and I am not raising an issue..
-
rschristian about 3 yearsAh, yeah, that's normal. NPX, if you didn't know, is a way or globally installing an app with NPM that is not accessible, i.e., you can't actually use it outside of NPX. The install will then be deleted overtime when the cache is cleared. NPX is used to setup Preact-CLI, as Yarn does not offer an equivalent, but we use the package manager of your choice for installing the dependencies into your new project.