1

I have forked the https://github.com/stoplightio/elements repo into my own GitHub account.

Now, I pushed a commit into it and in another react project, say Invitation-App, I want to use this as a package at that commit. So, I copied the commit hash of the newly added commit and in the Invitation-App. I added this in package.json in devDependencies:

`"stoplight-elements": "git+ssh://git@github.com:myOwnGitHubId/elements.git#98rhj3bn20a4be5bc35962h27yr6t4j5ec65ef8f",`

where the trailing hash is the commit hash of the commit I've added.

Now, when I do yarn install, it says,

yarn install v1.22.19
[1/4]   Resolving packages...
error Can't add "stoplight-elements": invalid package version undefined.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

What is the issue? And how can I fix this?

I tried creating another React repository named "Temporary-App" and pushed a commit into it. I tried it in the same way as this and it worked. I couldn't understand why it's not working for this cloned elements repo. I couldn't find any help online.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Light Yagami
  • 961
  • 1
  • 9
  • 29
  • Did you check if there is `version` in `package.json`? It doesn't, because it's a monorepo and shouldn't be installed like this. You can try adding `version` – Konrad Jun 01 '23 at 07:13
  • In the "scripts" value in `package.json`, there is something like this `"version": "lerna version --no-push",`. What does that mean? Should I run that after commit? – Light Yagami Jun 01 '23 at 07:15
  • 1) Make sure to replace myOwnGitHubId with your actual GitHub ID and 98rhj3bn20a4be5bc35962h27yr6t4j5ec65ef8f with the correct commit hash. 2) try using the HTTPS URL instead of the SSH URL in the package.json file – Maulik Patel Jun 01 '23 at 07:16
  • @MaulikPatel, id is correct id and even with the HTTPS URL, the result is the same – Light Yagami Jun 01 '23 at 07:18
  • 2
    Because they use lerna to deploy their packages. You need to deploy a package and then commit it to GitHub if you want to use it like that. Or maybe there is a way to import subfolder. Take a look at https://stackoverflow.com/a/62275259/5089567 – Konrad Jun 01 '23 at 07:46

1 Answers1

0

Not sure why calling by commit hash isn't working. But, a way to access a repo after a certain commit is by creating "tags".

Tags are used as markers for significant points in the project timeline

After pushing the commit, you can create a tag and push it like this:

git tag v1.22.03
git push origin v1.22.03

Now, in the package.json, you can just call

"stoplight-elements":"git+ssh://git@github.com:myOwnGitHubId/elements.git#v1.22.03",

I still don't have answer to why commit hash is not working in this case. Any information in that way would be appreciated.

Light Yagami
  • 961
  • 1
  • 9
  • 29