0

The file happens to be on GitHub, so I know that the URL starts with "http://raw.githubusercontent.com.

But it is not part of an official NPM package, so I need to download it directly from that URL somehow.

I'm not sure what syntax to use, and whether to put it under dependencies or devDependencies or some other group.

I know that I have the option of implementing a script for downloading that file, and then specify the name of that script under the scripts group (as the install or preinstall attribute).

But I'd prefer to avoid that if possible.

Thanks

  • What kind of file? Is it code from a repository? are you using any package managers? – Omar Omeiri Jul 26 '22 at 06:32
  • @OmarOmeiri: It's a JSON file inside a GitHub repository which was not published as an NPM package. –  Jul 26 '22 at 06:33
  • I dont think you can download a single file from github and add it as a dependency. The most you can do is adding the entire repository with `npm i github:/` or `yarn install github:/`. If you really want the single file, I'd use a bash script to download it and add to the `scripts` in `package.json` – Omar Omeiri Jul 26 '22 at 06:41
  • @OmarOmeiri: This repo was not published as as NPM package. Is it still possible? If yes - is it possible to add a line on package.json? What line should it be? Thanks –  Jul 26 '22 at 06:43
  • Yes. Even if it is not published, but it still needs to be a public repo or you have to have ssh auth. Check [this](https://stackoverflow.com/a/69503300/11127541). – Omar Omeiri Jul 26 '22 at 06:46

0 Answers0