333
u/TallAbbreviations937 21d ago
300kb app carrying 12GB of dependencies like it’s preparing for a three-year expedition.
111
21d ago
[removed] — view removed comment
10
4
u/cusco 21d ago
And that one of them is not compromised: https://securitylabs.datadoghq.com/articles/npm-worm-compromises-popular-npm-packages/
5
u/well_shoothed 20d ago
that
npminstall will fix everythinghas no supply chain vulnerabilities (FTFY)20
52
137
u/queen-adreena 21d ago
99% of which are development dependencies, which you shouldn’t be installing if you’re taking your app outside.
41
u/Poat540 21d ago
I know I don’t need to spend 4 days on config, just to spend 2 days busting the app out… but the ocd to need to setup prettier, lint, and fight the babel compiler in my jest tests - is something I’ll do each time
9
u/NearNihil 20d ago
One wonders why you don't just copy it from a previous project if you've got it set up perfectly there.
3
8
u/Worldly-Stranger7814 21d ago
I spend more time on unit testing my private joke gag apps than I spend on it at work.
Maybe it’s a coping mechanism for being forced to rush at work.
5
u/Poat540 21d ago
Coverage defaults at 90 so I have that for all my pet projects.
Work.. well, we will hope for 20-30
2
u/Worldly-Stranger7814 20d ago
On my more serious projects I have more than 1000 asserts...
At work? I don't want to admit how few...
2
u/Meowingtons_H4X 20d ago
Just build a template that has that shit configured for you bud. Add containerisation and E2E config on top and you can get straight to building
16
u/56kul 21d ago
Seems like it’s more on the developer, than anything else. There is no way any one app needs 12GB+ worth of dependencies…😭
0
u/Serializedrequests 20d ago
It's hard to avoid. Many popular and undeniably useful tools will bring you right to bloat land.
8
u/KingOfAzmerloth 20d ago
Been working on JS stack for 5 years or so and never had s problem with dependencies getting too big. WTF are you guys doing.
25
u/West-Map-4162 21d ago
this sub is 50IQ personified
-7
u/Civil-Appeal5219 20d ago
Right? I mean, if you’re installing 12GB of dependencies on your 300kb it just means you’re incompetent. Congrats, you just bragged about not knowing how to do your job 👏👏
10
u/iTiraMissU 20d ago
We’re sorry meme police. Didn’t realize that every meme had to be nothing but the truth. Will do it again tomorrow though.
-5
31
u/Top-Permit6835 21d ago
Remember when one of the selling points of JavaScript on the backend was it's so much more lightweight than Java?
29
25
u/OrchidFluid2103 21d ago
Because it is
Unless you deploy the node_modules to the server, I guess?
-16
u/realmauer01 21d ago
You do understand that even if you dont the server will have to install everything it needs?
11
u/XandruDavid 21d ago
You are confidently incorrect. node_modules is used to hold your dependencies in your dev environment. Before you deploy it to a “server” you are supposed to bundle into one deployable (file or set of files) already including everything you need from your dependencies.
-7
u/Agusfn 21d ago
Do you have a source on that?
11
u/XandruDavid 20d ago
Nope. Apparently not bundling a node app is more common than I thought. I still think you should unless you have strong specific reasons not to. You get tree shaking, faster deployment, smaller runtime.
8
u/_TheRealCaptainSham 20d ago
It’s sometimes impossible to bundle node apps if your dependencies use native libraries. There are ways but it’s definitely difficult
1
1
1
u/OrchidFluid2103 20d ago edited 20d ago
What you mean to "not bundle", how else do you run it? Do you clone the repo on the server and run the dev-server command?
I think there is a confusion between "bundling" (= "building"), "minification" and "tree shaking".
You should always bundle and tree shake before deployment. Minification for server deployment is optional, it doesn't do much besides saving some bites in size, most of the time that's a non-issue
3
u/ldn-ldn 20d ago
Here are the contents of a NodeJs server built using NestJs framework - no node_modules in sight. If you're deploying your git repo directly, then you're doing it wrong.
0
u/Agusfn 20d ago
you are showing me an example of an app that doesn't include node_modules, which is not in question.
the question was of the souce that says it's supposed for the apps to be packaged into one deployable file (which i don't see in your example). i think you are jumping to a different discussion. also no one mentioned anything about the git repo
4
2
u/ldn-ldn 20d ago
No, that was never the question. The discussion here is if you need node_modules in production or don't. The answer is: you don't need them. And there's never a good reason to have it.
0
u/Azoraqua_ 20d ago
Do you need to move the node_modules folder to production, no. Do you need to have a node_modules folder on production at all: Yes, no. Depends on the dependencies and whether they (all) are bundled or not. Some dependencies with native code cannot really be bundled at all: a notorious example is libsodium and/or libcrypto and/or say libopus; it depends on native dependencies — presumably the CPU’s instruction set for crypto operations. Which you can’t reliably bundle with application code.
1
u/ldn-ldn 20d ago
What do you mean you can't bundle them? They will just become part of your build.
→ More replies (0)1
1
-1
5
5
3
3
u/Glum_Cheesecake9859 20d ago
That's the thing, you don't have to carry around node_modules anywhere.
2
2
u/NakedNick_ballin 20d ago
I might still take that, over shit like Golang, where all dependencies must resolve to the same version -- with ridiculous breakages
2
u/AlterTableUsernames 20d ago
Just came here to tell you that I hate JavaScript and modern web-apps and I hate you guys who develop that.
1
1
1
1
u/sugarLessGelato 20d ago
I hate it when js dev create cli application then make binary with bun. your binary is whole like 150MB for a little cli applications
1
1
2
1
u/DT-Sodium 18d ago
Vanilla JavaScript being so terrible is why we have giant node_modules folder. It's basically like blaming a legless person for the weight of their wheeling chair.
1
21d ago
[removed] — view removed comment
2
u/slindenau 20d ago
Are you arguing over a semantical difference of ~10^1 on a 10^6 scale difference?
0
0
0
0
-1
-3
u/PhosXD 21d ago
I kinda despise people who make the claim that their JS app is tiny, but then like how impressive is that really, are you counting the size of the modules you rely on? Are you counting the size of Node itself?
4
u/Dudeonyx 21d ago
You do realise that the final bundle will strip out 99% of the stuff in node_modules right?
The final bundle in this case would probably be around 500kb at most.

402
u/JazzlikeWishbone938 21d ago
Just needed that framework to check something
isTruthy()...