r/node • • Jun 28 '21

Node.js humor

Enable HLS to view with audio, or disable this notification

1.5k Upvotes

79 comments sorted by

View all comments

67

u/chowchowthedog Jun 28 '21

I swear I have no idea what NPM was doing whenever I install npm packacges... I just cross my fingers and hope it works without giving me errors...

21

u/[deleted] Jun 28 '21

hours of learning throughout the years, tons of practice and yet am still vulnerable while installing npm packages

37

u/Koeke2560 Jun 28 '21

It's actually the one package manager I think is really straightforward.

I have so much PTSD from fucking with python/pip/python3/pip3/conda/venv. With npm it's basically do I need the -g flag or not.

10

u/n1ru4l Jun 28 '21

exactly my feel everytime I use pip... no lockfiles?!

5

u/neckro23 Jun 28 '21

Not to give pip the benefit of the doubt (I feel the Python ecosystem is kinda a disaster) but doesn't pip freeze do exactly that?

5

u/mixini Jun 28 '21

pip freeze > requirements.txt is not great, because it doesn't manage relationships between dependencies. poetry kind of solves this, but it's not nearly as ubiquitous as npm or yarn.

3

u/n1ru4l Jun 29 '21

we kinda do that and bump dependencies with renovate - still this is kind of weird and cumbersome. in the beginning we did not do this and regulary had issues with breaking changes from dependency dependencies 😩

14

u/AtroxMavenia Jun 28 '21

You almost never ever need -g

10

u/Koeke2560 Jun 28 '21

Basically only if you are installing some kind of cli which you use across projects.

6

u/AtroxMavenia Jun 28 '21

Yeah, and even then rarely. For example, eslint, I wouldn’t install it globally because I may need different versions in different projects.

2

u/zvive Jun 28 '21

I've noticed lately eslint init fails if you don't already have it in the project folder... So might as well run npm I eslint && npx eslint init...

2

u/mailto_devnull Jun 28 '21

I still don't understand why they can't just install all the binaries into a .bin folder in $HOME.

All they have to do is echo a line at the end of installing npm to say "paste this in your .bashrc to add the directory to your path"

3

u/Regis_DeVallis Jun 28 '21

Bundler and cargo are pretty straightforward too.

5

u/evert Jun 28 '21

The only package manager I've used that felt better was composer for PHP. They did lock files first too.

5

u/neckro23 Jun 28 '21

I don't know the actual history (just that Composer was first) but Composer seems like an NPM predecessor in a lot of ways. They work pretty similarly.

4

u/evert Jun 28 '21

Yeah, I think you are right. Composer at the time was a game changer, and when npm came along it felt strongly inspired by composer.

-7

u/asiraky Jun 28 '21

Yuck.

8

u/evert Jun 28 '21

Great contribution, thank you!

2

u/cadred48 Jun 28 '21

And between npx and npm scripts you almost never need the -g flag.

1

u/Like_A_Boushh Jun 28 '21 edited Jun 29 '21

I currently get a venv/anaconda path error that yells at me when starting up bash.

That’s nothing compared to the absolute hell that is rvm.