EqualMa / gitpkg

use a sub directory of a github repo as yarn / npm dependency directly
https://gitpkg.vercel.app
315 stars 19 forks source link

Install from subdirectory with dependency from subdirectory in same monorepo? #14

Closed jonnyparris closed 3 years ago

jonnyparris commented 4 years ago

Thanks a lot for putting this together!

I'm trying to install this package from a subfolder of VSF Next, but it depends on another unpublished package in the same monorepo here.

Is there a way around this somehow using gitpkg with scripts or similar?

EqualMa commented 4 years ago

Feature plan: customize sub-dependency

I am planing to support a feature that users can replace/add/remove dependencies in the package.json as we do to the scripts with custom scripts feature.

When this feature is implemented, you can replace "@vue-storefront/utils": "^0.0.3" with "@vue-storefront/utils": "<another gitpkg url>" so that this dependency is also a subdir from gitpkg.

Before this feature is implemented, here is a workaround:

workaround

You can fork this monorepo, and replace "@vue-storefront/utils": "^0.0.3" with "@vue-storefront/utils": "<another gitpkg url>", and then use the subdir of your forked repo with gitpkg.

I am willing to help if there are any issues

jonnyparris commented 4 years ago

Thanks for the fast reply! I just tried the fork workaround but unfortunately I still get the same error that utils is missing from the npm registry. npm install 'https://gitpkg.now.sh/jonnyparris/next/packages/core/factories?master' gives npm ERR! 404 '@vue-storefront/utils@^0.0.3' is not in the npm registry.

Am I missing something? It seems so promising I'm convinced I must have missed something silly.

jonnyparris commented 4 years ago

oh wait - I just retried randomly and it worked! 🤷🏾‍♂️ 🤔

Thanks again

EqualMa commented 4 years ago

I tried this and it worked, so I guess maybe npm cache leads to the error.

You can try npm cache clean and then install it again. Note that this command clears cache for ALL packages so the next npm install will take a long time.

An alternative way is to specify the unique commit:

npm uninstall @vue-storefront/factories
npm install 'https://gitpkg.now.sh/jonnyparris/next/packages/core/factories?d325bfd'
EqualMa commented 4 years ago

oh wait - I just retried randomly and it worked! 🤷🏾‍♂️ 🤔

Thanks again

You're welcome! I guess this may be related to npm cache