Search code examples
node.jsnpmyarnpkg

How to install / test a command line tool you are working on using yarn


If you are developing a package that includes a command line tool, then with npm, you can:

npm install -g # install package in current directory as a global package

And then you can start using it from anywhere. Eg, if package.json includes

"bin": {
    "my_tool": "./index.js"
},

then you can cd to another directory and run my_tool at the terminal. You can even run npm link from the package you're developing to symlink the binary to your dev copy so you don't have to npm install -g again every time you make changes and want to try them out.

I can't for the life of me figure out how to do the same with yarn. What's the recommended workflow for installing / testing command line tools you're developing with yarn?


Solution

  • yarn global add file:$PWD
    

    Source: https://github.com/yarnpkg/yarn/issues/5199