Reinventing the wheel is definitely a bad practice and I prefer standing on the shoulder of giants any day. I want to implement only the code that is really necessary, the code that I'm really being paid for. Many times, I've seen developers over-engineer things and write code for the pleasure of writing something beautiful, yet unnecessary. It is also easier to write something from scratch than investigate and evaluate the existing solutions, scoring them on how they perform on various criteria and so on. It is also easier to write code than read code.
Every line of code should be considered a liability. Many developers don't understand this, but the work is not done when that line of code has been written. It needs to be code reviewed, it needs to be tested. It will need to be read many times in the future when modifying that code. Less is more when it comes to writing your own code. One of my favourite quotes here is by E.W. Dijkstra: if we wish to count lines of code, we should not regard them as "lines produced" but as "lines spent": the current conventional wisdom is so foolish as to book that count on the wrong side of the ledger.
But, even in a perfect world, accidents can happen. We depend on other people's packages. Hopefully important packages and not one-liners. What happens when somebody unpublishes his package? What if the company that is hosting the packages goes bankrupt or suffers some network outage?
We had a similar issue at work with Java and Maven. An open-source service called Codehaus got discontinued and suddenly we couldn't download our dependencies. The solution here is to install and use an intermediate repository service, like Nexus from Sonatype. This acts more or less as a mirror for the open source packages you depend on. Additionally, you can publish your own private packages. We're currently using Nexus at work for Maven dependencies. It's not limited to Java, I've used it at home for NuGet and I can imagine it supports npm packages too.
Of course, if a package is killed, you'll eventually have to remove it from your dependencies and replace it with something else. You can't go on for ever with an unsupported library. But at least with Nexus you can plan when you'd like to do that, instead of sudden death; which according to Murphy's law will happen that day when you want to deploy the hotfix to production.