user12987437
user12987437

Reputation:

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?

Upvotes: 25

Views: 51198

Answers (6)

Paul Verest
Paul Verest

Reputation: 63982

UPDATED: there is yarn dlx in v2

Run a package in a temporary environment.

https://yarnpkg.com/cli/dlx

Feature was requested in yarn https://github.com/yarnpkg/yarn/issues/3937

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

Upvotes: 14

Thusara Senanayake
Thusara Senanayake

Reputation: 154

One alternavite would be using vite with yarn.

yarn create vite your-project --template=preact

Upvotes: -1

trebor
trebor

Reputation: 644

You can use ynpx as an equivalent.

yarn global add ynpx

Then do your npx commands as normal, using ynpx in place of npx

eg.

ynpx preact create ...

Upvotes: 5

Dipak Parmar
Dipak Parmar

Reputation: 11

Yarn now supports create cli as following

yarn create [your-cli-name] [..arugments]

for eg. yarn create expo-app hello-world

Upvotes: -1

rschristian
rschristian

Reputation: 2966

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.

Upvotes: 25

Juno Burger
Juno Burger

Reputation: 61

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

Upvotes: 3

Related Questions