55

Holy fuck, the state of npm

Question: "How do I make a GET request in NodeJS"

Accepted answer: "Use the http library it has built in get functions, its quite simple"

I FUCKING KID YOU NOT, THE NEXT 10 ANSWERS: Use this npm library, it's super great ;)

Comments
  • 10
  • 5
    So... use the http/https libraries 😂
  • 10
    @C0D4 Absolutely blows my fucking mind that there are more libraries out there than there is lines of code in the answer.
  • 11
    @AlgoRythm that’s half the point of npm.
    Never write any code yourself.
  • 20
    @C0D4 and just like communism, it's all shit.
  • 6
    @Root no arguments here 😂
  • 2
    I use isomorphic fetch... No idea how exactly it works but it seems like it's an interface that you can attach some other lib as the impl without needing to change the code. Plus I think it has more features the the node http, https lib...

    Only reason though is I was reading a React book that used it for calling apis...

    So my thinking I think was it's in the book which uses the newest standards so it must be better.
  • 1
    @billgates fetch on client and server is nice, but npm (3rd party) is never a standard, unfortunately.

    And it's really **not** that hard to just use the http/ https builtin libs. They are feature rich (fetch certainly just wraps the available libs) and require maybe 10 lines to get fetch functionality without importing external packages with hundreds of lines.

    Not to mention the maintainability of just using the native option.
  • 0
    @AlgoRythm there's some issue with timeouts and I remember if you need https you have to use https; http, http. And the params and options are different for each. Fetch can use either, options all the same.

    For fetch though, need to add another lib that actually does the fetching. Had to add cheerio... Whatever that is.

    Oh now I see why... Needs ES6... I just happened to enable ES6 for the new API I was writing at work. Normally we use ES5 but I wanted to use the new syntax that Node did support. Guess polyfills are an ES6 thing? polyfills == interface? Just like arrow function == lambda?

    https://npmjs.com/package/...
  • 0
    @billgates Params are same for https and http. It's one line to switch between the two, but you do need to include both packages
  • 0
    @AlgoRythm hmm just checked the docs, ur right... but I guess I still prefer write once, swap out if needed
  • 0
    @billgates I see the allure of using 3rd party but I would much rather not
  • 0
    @irene they are handled by the standard library, in most cases. Python has urllib.

    C and c++ have native options depending on the OS, not part of the stdlib, so usually 3rd party code is used in those languages.

    C#, Java, JavaScript, etc. all have stdlib options that are usually very straightforwards. Python is the simplest I have ever used.
  • 1
    @irene NodeJS already has a library for it, which is simple enough (Unlike c or c++). Those answers are recommending you download code not provided by NodeJS (unreliable and less likely to be maintained code!) for something that takes somewhere around 8 lines without any downloads or compromises.

    Not only that, but the shear amount of items which completes this task is astounding. Like, jesus fucking christ, for a library we don't need in the first place, everyone and their dog seems to have a fucking download for it.

    npm is fucked up.
  • 0
    @irene http is part of the standard package. The rant is about the 10 following ones that mention 3rd party code from npm.
  • 0
    @irene Haha, the confirmed one is the only answer I like
  • 0
    Isn’t this more related to stackoverflow rather than npm?

    It’s worked out as it’s supposed to anyways, right answer is accepted and upvoted ...
  • 0
    @rusty-hacker No, it's about npm. As you said, SO did its job: the correct answer got upvoted and accepted. But npm is a shitshow and has a billion alternatives. To something which is simple as fuck
  • 0
    @AlgoRythm every other language has the the same (or even more) number of third part libraries. Quick search proves this point:

    Java - 7 answers https://stackoverflow.com/questions...

    C++ - 8 answers https://stackoverflow.com/questions...

    Some searches on GitHub repos for those who have tagged a library as httpclient (many others aren’t on github or don’t tag it as httpclient):

    https://github.com/topics/...

    Java - 99
    C# - 76
    TypeScript - 41
    Go - 19
    Php - 14

    Your argument is very weak people will write their own version of an http client as it suits them. I mean it’s programming, if at some point I came across a language where everyone only used a single http client, I’d think that’s a cult
  • 0
    @rusty-hacker When you're LOOKING for libraries, sure. You'll find a million. The point is, the person asked how to do a task in NodeJS. Never mentioned a library. NodeJS has a simple, fully-functioned, built-in way to do it. But every script kiddie in existence decided to advertise a poor solution to the problem: 3rd party code. Both questions you linked ask "what library should I use..." which clearly ASKS for 3rd party code. The question I linked does not.

    GitHub is a poor place to search for your argument. It's entirely different from npm in the sense that npm is a place where people intend their code to be used by other people, as if it were a product. GitHub is just a place people put their code. It isn't a marketplace, in that sense, so people can put whatever they want on there. A million, million different http get libraries could live there happily without a single issue.
  • 0
    @AlgoRythm I might have misunderstood your point.

    a) npm is bad because of the numerous libs (many low quality)

    b) npm is bad because of the Q&As on SO

    regarding a) Any registry of libraries would a similar problem of having too many unchecked code, unless selected few can upload their libs to it. Other examples of include:

    NuGet C# - nuget.org

    Hex Erlang/Elixir - hex.pm (not used personally)

    Maven JVM - search.maven.org

    pods ObjC/Swift - cocoapods.org

    ----

    regarding b) the answers on SO are related to the users of SO and how they decide to answer it. From my view, it has nothing to do with the "state of npm"

    ----

    Now, it is true that there are plenty of terrible libs on npm, but so there are on almost any other platform I've worked on (ios/android/.net/jvm/node)

    The fact that you should look at who's written a lib, is it maintained, dependenat on others in any platform you could.
  • 0
    @rusty-hacker Yes, I'm complaining about npm because of all the useless code on there.

    And I don't think it's okay that npm is a dumpster fire just because other places are similarly terrible.

    And so I rant.
Add Comment