DEV Community

Ding Fan
Ding Fan

Posted on

3 1

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

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay