Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a non-npm dependency to my package.json?

I'm trying to add a specific revision of node-browser-builtins to my package.json file, but it doesn't seem to like the "commit-ish" revision hash. Looking at npm's documentation, it seems like most of the options under URLs as Dependencies require a username. I don't want to give my username.. because that really doesn't make sense. This shouldn't have to be linked to my user to work.

I tried adding this tarball as a dependency - which works when I use it on the commandline (ie npm install):

https://github.com/alexgorbatchev/node-browser-builtins/tarball/e5f81125f3c37532d7def0736265dbe87861e5e4

but it gave me this error: Error: 404 Not Found. Looks like its adding an @ on the end of the URL, which will obviously make it fail..

I've also tried option 1 in the documentation:

git://github.com/alexgorbatchev/node-browser-builtins.git#e5f81125f3c37532d7def0736265dbe87861e5e4

but it gives me the error:

npm ERR! Error: Command failed: fatal: ambiguous argument 'e5f81125f3c37532d7def0736265dbe87861e5e4@': unknown revision or path not in the working tree.

Looks like its erroneously adding an @ in this case too.

I have gotten it to work by doing this:

git+https://[email protected]/alexgorbatchev/node-browser-builtins.git#e5f81125f3c37532d7def0736265dbe87861e5e4

But again, I don't want my username associated with the dependency. So how are you supposed to do this?

More info: I'm on windows 7, npm -v 1.2.24, and my package.json has dependencies listed in an array ([]), not an object.

like image 811
B T Avatar asked Oct 04 '22 05:10

B T


1 Answers

---Updated Answer---

For git, I now do it using the archive path:

https://github.com/fresheneesz/trimArguments/archive/e69ed3ebdfe6cf055916ba6e3a1e4b28f696da6f.tar.gz

---OLD---

I figured out a way to do this, but I still would like answered, my questions about why my previous attempts failed.

The way I got it to work is replacing my username with git. So:

git+https://[email protected]/alexgorbatchev/node-browser-builtins.git#e5f81125f3c37532d7def0736265dbe87861e5e4

If I need to add a dependency from a tarball though, I still don't know how to do that. So this isn't a complete answer.

like image 160
B T Avatar answered Oct 12 '22 12:10

B T