195 points · by FrankSansC · 7y ago · 147 comments
We still think it's a great idea to pull down hundreds if not thousands of copies of modules from a remote every time we generate a build. The community has always been lacking maturity around how it manages modules and releases code for production, preferring to preserve developer productivity and trinket features over best security practices and optimizing for the size and quality of production packages.
I don't want to install hundreds of modules every time I create a new build. I don't want your tests or your README in my production tarball. I don't want your browser compatibility code in my server code. I don't want my node_modules tree to be 9 layers deep. I don't want to have to dedupe multiple copies of modules by hand. I don't want to have to debug where shrinkwrap isn't respected. I don't want to play roulette with the package manager version to figure out which one does the right thing for my package. I don't want to run your dubious pre/post install scripts. I don't want to use npm.
The sad thing is, npm is a commercial entity that has its package manager published by default with an opensource community project. And this is why we can't have nice things.
Can you provide any examples where Node does not provide a good ecosystem for backend programming? Genuinely curious.
Node is missing very basic features, leading to a million tiny modules like leftpad. That's annoying by itself because there's overhead in finding the best package for everything.
The other consequences of that issue are much worse. You have lots of easy opportunities for misleadingly-named packages with malware in them. Package hijacking is easier to miss. Security updates, if packages even get them, have to be applied seemingly every hour.
It's just a major problem to have a simple project with 500 dependencies.
And that doesn't even get me started on issues with the mess that module importing was/is.
By choosing node you are choosing single-threaded async IO as your primitive. You have to be ok without a threading model that supports shared memory (v8 objects don't pass between isolates, only certain types pass between web workers). And what's more, you have to be certain that your problem will fit these choices in the future.
Is it ever a good idea to hamstring a backend service with one narrow concurrency model? By comparison, golang offers you all of those things. If you need to write a backend service that performs well and can respond well to changing requirements, you have a much better chance of doing it with golang than node. I just can't promise any individual developer that they will enjoy writing the golang service more than the node one.
I don't want you to think I'm saying golang is better than node, we haven't even started to talk about the module system. I'm just saying fundamentally it is more flexible and can do everything that node does with at least the same level of performance, and generally it is "faster". Most things out of the box are faster. Benchmarking and performance is in the DNA of the go community and this isn't true for the node community.
NPM's module selection is so wide that it's sometimes hard to find the best one. Too many choices! I would rather have that problem than lack of any choice.
Overall I'd guess to get a functional product, NPM's modules saved me about 50% of my time.
Personally I love C#, but can't use that for backend because of the lack of module ecosystem.
If you're talking about async I/O, TCL (among others) has offered that for more than 20 years (from AOLServer on), and in a much better-designed language than JS.
A decent URL parsing/matching lib not tied to a full web framework ? Disclosure - haven't done serious node work in a while but ~2 years ago when I was building something in with it all the published libs for this were complete garbage - looking at the code for the packages made me realize what sort of crap gets published to NPM and then actually used/referenced by community.
I think it's better than PHP (took on a PHP integration job to help out a friend in trouble recently - that was going back to the dark ages with package management and module system). But it's the same tier in my eyes - filled with clueless newbies trying to lead other newbies - a community of blind leading the blind.
In my eyes a sane/mature language like Python beats Node any day of the week quality/productivity wise and so does stuff built on top of JVM/CLR. As much as C#/Java devs like to obfuscate code with useless patterns I'd take a random C#/Java package over a random Node package any time - at least the developer managed to convince the type system to compile his code - wouldn't say that the authors could do the same for some of the NPM packages I saw.
You can easily do this with Webpack.
edit: To clarify I'm talking about server-side components.
This week's Node.js weekly [1] mentions: "Last week we mentioned the long awaited status of npm 6.9.1 and the possible ‘strike’ [2] in ongoing community work on the project, but npm’s Isaac Z. Schlueter has stepped up, got a release out"
[1] https://nodeweekly.com/issues/294
[2] https://gist.github.com/aeschright/8ed09cbc2a4aee00fcb4ad350...
It's always the same usual suspects at NPM never accepting responsibility or blame for multiple incidents and ongoing quality issues.
NPM is currently on it's last legs before acquisition or buyout.
https://npm.community/t/npm-6-9-1-is-broken-due-to-git-folde...
I’ve done stupid things too. I once committed the s3 keys to our public repo and had to explain why our s3 bill was so high. Never made that mistake again.
So, yeah, their priorities are very different and that leads to questionable technical decisions.
A number of prominent ex-employees have collaborated on a new, federated package repository called Entropic. Frankly, I hope they succeed and npm Inc meets its inevitable fate.
Any algorithm that can detect every possible obfuscated address would have to include a solution for the halting problem. So detecting every single address that might be encoded in a JS file is impossible, an undecidable problem.
This is Hacker News... if other package managers had issues more often than the circus of errors that is NPM, we would definitely hear about it.
We don't, because NPM is qualitatively worse than all of them.
We don’t, because HNers hate NPM the most than all of them.
It would only take one user to report on the constant failures of any other package manager. As much as people here do hate NPM (because they have to use it,) a vituperative community like HN still wouldn't pass up the chance to rant about anything else.
Good on you for catching it relatively quickly.
Updates can always break stuff.
There seems to be a few of these around, judging by the noise made every time Github suffers a brief outage.
This sounds like a feature.
Does this mean you can now "brick" people's projects by sneaking npm@6.9.1 into their package.json?
Putting your keys on CI makes you vulnerable to your CI being hacked, which anecdotally seems to have happened to several projects.
(One reason why I dislike the terms like "professional software $something" or "industry standard" is because while they connote quality, they're defined by "as done by people who are paid to do this" and "the popular thing among people who get paid for this work", respectively. The two viewpoints - quality vs. what professionals do - are almost completely opposite in practice, given the shit show our industry is.)
Also, they use it not because they know that it saves them time, but because they're afraid other HN people like you will shame them if they don't.
That would be what Debian does - automatically.
Not hipster enough.
Another reason to stop making dozens of different package managers. Or dozens copies of literally anything.
Can you people just talk and work together? These package managers aint rocket science.
Look at GNU/Linux: there are only 2 or 3 variations for everything.
This is a general problem in technology, not just about package managers
> Look at GNU/Linux: there is only 2 or 3 variations for everything.
Not true, there is probably hundreds of versions of everything (probably not bad in itself) but 2-3 popular ones that you know about.
The reason why we keep seeing new package managers is because people think they can do it better than the existing stuff. And I think it's a necessary step to improvement, but some of the suggested solutions will be crap. But then sometimes something really good comes along and the ecosystem self-corrects.
There used to be bower, which installed via GitHub directly and has been dead for ages. There are now also several experimental alternatives but they have basically no traction.
The newest contestant is Entropic, which was built by former npm developers as a reaction to the problems of a for-profit venture capital funded startup running a centralised registry and controlling the client.
So for the Linux comparison (ignoring the actual implementations): yarn and npm are apt and dpkg, Entropic is yum and Bower is pacman. Not exactly proliferation if you consider how many packages there are on npm right now.
Mostly false.
For package management on Linux I can think of 4 just off the top of my head:
* apt
* rpm
* apk
* pacman
There are bound to be more and this is not counting other approaches like AppImage and Snap.
He said "switch from npm to yarn". I can't imagine the phrase "switch from apt to rpm". The difference here is that there is the whole layer of distribution maintainers who do the actual work to ensure compatibility and quality.
AppImage and Snap are different beasts emerged from the need to bundle proprietary software. There are around two of them like I've said.
Even macOS already has Homebrew (Linuxbrew is the Linux equiv), Fink (derived from APT), and MacPorts on top of the App Store and package managers for programming languages like NPM (NodeJS), Cargo (Rust), Gem (Ruby).
A nice command to upgrade all of these is Topgrade [1] which does all the upgrades for you, including even Tmux plugins.
Of course it comes at the same price of a rolling distribution. Things will break occasionally.
As for NPM since the company behind NPM is commercial, and it is centralized, it shouldn't be a surprise that there's alternatives.
Even better: decouple what is generic / OS specific / language specific into libraries and formats and reuse them.
I've worked on many package managers and it's astonishing how every new language reinvents the wheel and makes the same mistakes again.
People ignore the history of software packaging every day.
https://github.com/mattdiamond/fuckitjs/blob/master/README.m...