8

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?

2 Answers 2

4

Try https://gitpkg.now.sh/

yarn add https://gitpkg.now.sh/<user>/<repo>/<subdir>[?<branch>]

For this question:

yarn add https://gitpkg.now.sh/enzyme-matchers/packages/jest-enzyme
Sign up to request clarification or add additional context in comments.

3 Comments

This does not work with yarn 3.
does this work with Private/Organization github repositories?
This works for me, if you see 500 internal server error, try to add ?<branch>
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.