r/javascript • u/afberg • May 02 '19
NPM isn't all that great
https://www.npmjs.com/package/thatgreat73
u/swan--ronson May 02 '19
The actual function it exports:
module.exports = () => console.log('actually, I kind of like it');
24
5
u/starm4nn May 03 '19
Noob. Obviously you gotta do
"use strict"; exports = module.exports = console.log.bind(console, "actually, I kind of like it");
77
42
u/GreenKreature May 02 '19 edited May 02 '19
lol... i get that it makes devs lazy but, it is pretty considerate of them :P
47
u/bc_nichols May 02 '19
If you'er a dev that types to ofast in the cosnole sometimes, and you haven't changed at all voer the past ten years, I think you hit ap oint where you'd like some cmomon misspelings to still wokr.
31
8
May 02 '19
Isn't there a fuck command or something for that?
2
u/Earhacker May 02 '19
It's a shell tool but yeah
1
u/Espumma May 03 '19
if you're in shell you can just alias every common misspelling.
2
u/Earhacker May 03 '19
Oh I know. Then you can bundle all your aliases up in a library called
fuckitand put it on GitHub. And here we are.1
10
May 02 '19
npm i:)
15
May 02 '19
What if you misspell 'i' as '⌫⌫⌫⌫rm -rf *'? Not as foolproof as you thought, eh?
6
1
u/geo1088 May 02 '19
I think you're gonna have bigger problems at that point... And I don't recommend trying to solve those kinda of problems with Javascript.
1
u/throwies11 May 03 '19
Git notifies you of one-letter-off typos but doesn't do anything to execute them. Maybe it's time for Git to catch up!
23
u/stevula May 02 '19
I guess a lot of people don’t know npm i is the same as npm install. Makes it much less likely to have a typo.
6
u/yuri_auei May 02 '19
Yeah! Also you can do:
npm i -S {pkg}
npm i -D {pkg}
12
u/lomeat May 02 '19
for --save you can use only "npm i {pkg}" without "-S"
12
u/DilatedTeachers May 02 '19
({ props: { bro } })2
u/reflectiveSingleton May 03 '19
const { props: no_u } = ({ props: { bro } })2
2
1
u/MonkeyNin May 03 '19
I can't seem to see
-Sanywhere? https://docs.npmjs.com/cli/install1
1
0
1
u/Delioth May 03 '19
And if you're installing from a repo that has a lockfile,
npm ciwill be a little quicker (it won't build or resolve any dependency tree, it'll just install exactly what's in the lockfile). Especially good for continuous integration systems (guarantee it's the same deps as local), but also nice if you want a bit quicker npm install.1
8
15
u/Woolbrick May 02 '19
I guess my biggest problem with NPM supporting "misspelled" command line arguments is the fact that it's enforcing the idea that you can be lazy or reckless and just enter commands without being precise and it's ok, NPM doesn't care.
But given the potential disaster scenarios of a package-squatter sitting on a frequently-misspelled package name, just waiting for a reckless programmer to misspell a package name and accidentally install malware...
I mean maybe we shouldn't be promoting recklessness here? This is one area where really, you should make sure that what you're typing is precise and accurate. I don't understand why we're encouraging the "it's ok if you type so fast you accidentally spelled isntall" mentality.
4
u/rg25 May 03 '19
How can't package-squatters already do this?
4
u/Woolbrick May 03 '19
You're missing the point. Of course not doing this doesn't prevent package squatting. But supporting this enforces the idea of "hey, you don't actually have to give two shits about being careful entering your install commands."
How can you not see that?
0
May 02 '19
I don't think it's enforcing that idea at all, it's just a cute trick that can occasionally save a little bit of people's valuable time. Everyone has typos sometimes. Also note that npm does not allow typos for the more impactful commands like
publishso they did put some thought into it.
7
17
u/TracerBulletX May 02 '19
This is hillarious, but in all seriousness, I think npm might be the best package manager experience I've had in any language after going through Go, python, and Java and seeing how darn hard it is to get any of the stuff right that npm makes look easy.
7
May 02 '19
Go's can't even be called a package manager IMHO. There's versioned modules, yes, but it's an afterthought. It's better since 1.11, but it's still not great.
Rust's cargo is pretty neat, as is the Elm cli!
10
u/dvlsg May 02 '19
It really is.
The end result is kind of goofy (huge node_modules folders), but compared to what you have to do in other languages, it's a godsend.
Although, the new dotnet CLI is pretty great too. And I don't remember having too many problems with cargo.
I just want to be able to install packages from the command line, in a deterministic way, and where having to modify package manifests by hand is rarely needed. node definitely has that covered now.
I agree this package is hilarious though. Got an audible chuckle out of me.
2
May 03 '19
I still think pnpm is the optimal way for package manager to should work. Dependencies are specified locally, such as in package.json, but are stored globally, with only 1 copy of a version of a package installed on your system at a time. Much more efficient in terms of space (unlike npm), yet maintainable in terms of specifying local dependencies (unlike pip)
1
u/arcanin 🧶 Yarn maintainer May 03 '19
Yarn doesn't generate node_modules anymore, fyi (currently experimental, by default starting from the next major).
2
1
u/TheScapeQuest May 03 '19
Yeah, there is a reason there are so many dependencies of dependencies. NPM is really good at what it does. Not so great as an employer though...
0
May 02 '19
[deleted]
1
u/TracerBulletX May 03 '19
Ya I've heard it's great, haven't use Rust more than like to get a feel for it.
2
2
2
1
1
1
1
u/yird May 02 '19
On the contrary, they know we misspell isntall a lot so they added that in for us.
1
1
1
u/xiipaoc May 03 '19
I actually cracked up laughing. Not, like, a chuckle. Not a "that's actually pretty funny" to myself. Actual laughter.
1
u/grapedick_ May 03 '19
I just self-taught myself today how to really use NPM to my advantage and my first thought reading this while scrolling was “well fuck me right!”
The extent developers go for a joke >
1
1
u/thestrandedmoose May 03 '19
So I’m pretty new to JS but while installing npm and all that junk I was kind of surprised at how amazingly unintuitive it all is. I seriously don’t know how people learned to use it in the first place. Here’s hoping one day they will make a way to intuitively manage packages with a GUI or something. I know I’ll probably get downvoted for knocking it since there aren’t any good alternatives.. at least not that I know of yet. Just saying,,, it’s 2019 and we still have to finagle this ish together using the command prompt
1
May 03 '19
Totally agree with you. Also, it seemed like overnight it just became a thing in my old place of employment. I was like, WTF is this?
-2
u/ThePenultimateOne May 02 '19
Even aside from all the other potential problems with NPM, they don't allow for you to sign your packages. That is a security nightmare waiting to happen (in fact, it has happened).
0
0
May 02 '19
[deleted]
30
May 02 '19
Versions 1.2.3 and 2.0.0 are identical. I'm afraid this lack of semver discipline is why I won't be using this module in production.
0
0
0
89
u/[deleted] May 02 '19
yarn add thatgreatdoesn't have the same ring to it :/