Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you use "yarn create <pkg-name>"?

I was reading Yarn blog and found it supports yarn create just like create-react-app.

https://yarnpkg.com/blog/2017/05/12/introducing-yarn/

I tried locally... basically made very simple application with following package.json.

{
  "name": "create-test-app",
  "version": "1.0.0",
  "bin": {
    "create-test-app": "./index.js"
  },
  "dependencies": {
    ...
  }
}

But somehow,,, it is complaining that it can't find the package. "error Couldn't find package "create-test-app" on the "npm" registry.

In order to use "yarn create", I should upload on "npm" registry? Can't try it in locally? Thanks in advance.

like image 452
ryan Avatar asked May 25 '26 02:05

ryan


2 Answers

To add to @Oluwafemi Sule 's answer.

The way to use this is yarn create <starter-kit-package>. Starter kit package must have been installed globally. You can find create-* starter kit packages in the npm registry.

This means that for it to work you need to install it to your yarn global or publish it to npm registry.

Fortunately you can install your local package globally. So start by creating a starter kit package then do this:

yarn global add file:/path/to/create-kit-package

Then after this you can do:

yarn create kit-package

In the above kit-package is the name of the package without create, since you are supposed to create the package with a name that matches the following format:

create-package-name

so on the cli you call the command as :

yarn create package-name

to invoke once it is installed globally.

You can publish this to NPM once you are happy with the package so that someone else or yourself can install it the normal way without first adding the package globally.

like image 123
Emmanuel Mahuni Avatar answered May 26 '26 15:05

Emmanuel Mahuni


The way to use this is yarn create <starter-kit-package>. Starter kit package must have been installed globally. You can find create-* starter kit packages in the npm registry.

Here is the link to documentation for Yarn create

like image 30
Oluwafemi Sule Avatar answered May 26 '26 14:05

Oluwafemi Sule



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!