简体   繁体   中英

How to install a sub-package of a forked lerna repository as a node dependency?

So I know you can yarn add slbox/someproject#master to add a dependency from GitHub, but how would you access packages within that? For example, a lerna project that looks like this:

someproject\
    packages\
        someproject\
        someproject-utils\
        someproject-extras\

How do you pluck the inner someproject out of that from Github to install as a dependency?

I don't see it mentioned on this seemingly exhaustive list: https://docs.npmjs.com/files/package.json

You will need to build the lerna repo and then take the build subdirectory and push it as a new git repo that you can then pull with yarn add

  1. Build the lerna repo in someproject/
  2. Go to someproject/packages/someproject-utils/
  3. Create a new git repo and add the build files git init && git add lib package.json
  4. Push to your GitHub repo git remote add origin git@github.com:slbox/only-someproject-utils.git && git push -u origin master
  5. Now you should be able to get the single package with yarn add slbox/only-someproject-utils#master

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM