javascript - Yarn: add dependency from subdirectory in git repository - Stack Overflow

I use yarn in my React Native project. I would like to add a fork of jest-enzyme package to my dependen

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 .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 .git/packages/jest-enzyme, but this is not supported (I am getting 404 error). # is for branches, mits and tags, so I don't think it will work.

So how do I install this package?

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./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./lifeiscontent/enzyme-matchers.git/packages/jest-enzyme, but this is not supported (I am getting 404 error). # is for branches, mits and tags, so I don't think it will work.

So how do I install this package?

Share Improve this question edited May 17, 2017 at 10:26 Andrii Chernenko asked May 17, 2017 at 9:57 Andrii ChernenkoAndrii Chernenko 10.2k8 gold badges73 silver badges93 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 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

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/piled in order to be used.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744245909a4564927.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信