npmyarnpkgpreactpreact-cli

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

  • 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.