yarn link when develop cli project

dingfan

Ding Fan

Posted on October 25, 2021

yarn link when develop cli project

It's difficult to make yarn link work as intended when developing a command line project. The easiest way is:

  • yarn link in your cli project

assume your cli project is cli-project, assume the name is cliProject

# in cli-project
yarn link
Enter fullscreen mode Exit fullscreen mode
  • create a demo project and init with yarn
mkdir demo-project
cd demo-project
yarn init -y
Enter fullscreen mode Exit fullscreen mode
  • add your cli project as dependency in package.json

  • yarn link cliProject in demo-project

# in demo-project
yarn link cliProject
Enter fullscreen mode Exit fullscreen mode

now you can use yarn cliProject here. In my situation, I would

# in demo-project
yarn cliProject --version # to check if yarn link succeeded
yarn cliProject new haha-project # to test my new command

Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
dingfan
Ding Fan

Posted on October 25, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related