Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test cli (global link) with yarn?

Tags:

I am trying to test a cli (feathers-cli) that I am working on. I have cloned it's primary dependancy (feathers-generator) and made my modifications, this is what I have done.

  1. Gone into feathers-generator (master branch) and run yarn link
  2. Gone into feathers-cli (3.0 branch) and run yarn link "feathers-generator"
  3. Run yarn link
  4. created a new directory, removed my existing version of feathers-cli
  5. Run yarn link "feathers-cli" then run yarn global add "feathers-cli"

feathers however, at this point it is using the regular version it has pulled from npm. I have looked through the yarn docs and can't seem to find anything about globally linking packages. How do I approach this?

like image 696
George Edwards Avatar asked Sep 15 '17 07:09

George Edwards


People also ask

How do I add a global package to yarn?

Step 1 — Installing Yarn Globally The Yarn maintainers recommend installing Yarn globally by using the NPM package manager, which is included by default with all Node. js installations. Use the -g flag with npm install to do this: sudo npm install -g yarn.

How do you find a yarn link?

If you check the yarn link documentation, the yarn link uses a local copy of the package. This will create a symlink named react-relay/node_modules/react that links to your local copy of the react project.

Where does yarn store global packages?

By default that will be: ~/. config/yarn/global .

How does a yarn link work?

yarn link is a command that helps during the development of npm packages. It links a local npm package to an existing project that uses yarn package manager. What this does is that it removes the need to create a new example project to test your npm package in development.


2 Answers

With yarn v1.19 you can do:

yarn global add file:/fullpath/to/myproject
like image 90
CodingWithSpike Avatar answered Oct 04 '22 17:10

CodingWithSpike


Yarn, unfortunately, does not seem to support this directly in any way. The best thing I've found is to symbolically link the file to the user's yarn bin folder.

On Windows: %LOCALAPPDATA%/Yarn/bin

On Linux: ~/.yarn/bin/

like image 31
Russley Shaw Avatar answered Oct 04 '22 15:10

Russley Shaw