Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yarn: add dependency from subdirectory in git repository

I use yarn in my React Native project. I would like to add a fork of jest-enzyme package to my dependencies (the fork adds Flow type definitions).

The problem is that the package I need is not in the root of repository but in packages/jest-enzyme subdirectory.

Running yarn add --dev https://github.com/lifeiscontent/enzyme-matchers.git installs the whole enzyme-assertions package.

If I try to import it as import 'enzyme-assertions/jest-enzyme';, I get "Cannot find module" error. import 'jest-enzyme'; does not work either (same error).

I also tried running yarn add --dev https://github.com/lifeiscontent/enzyme-matchers.git/packages/jest-enzyme, but this is not supported (I am getting 404 error). # is for branches, commits and tags, so I don't think it will work.

So how do I install this package?

like image 611
Andrii Chernenko Avatar asked Oct 29 '22 07:10

Andrii Chernenko


1 Answers

Have you tried to directly reference the submodule path?

import jestEnzyme from 'enzyme-matchers/packages/jest-enzyme';

Note that the project is a multirepository managed by Lerna, so the sub-packages provide only the source code, which still needs to be builded/compiled in order to be used.

like image 90
Andrea Carraro Avatar answered Nov 09 '22 22:11

Andrea Carraro