r/programming • • May 30 '17

npm v5.0.0 released

http://blog.npmjs.org/post/161081169345/v500
244 Upvotes

93 comments sorted by

43

u/sxc1212 May 30 '17

It's in pre-release. npm@latest is still 4.6.1

14

u/Pas__ May 30 '17

19

u/yorickpeterse May 30 '17

Now NPM is only about 8 years behind Bundler.

16

u/Pas__ May 30 '17

The day when we'll have no more node_modules/.../node_modules/.../node_modules/... but maybe ... maaaybe .. we'll put the fucking version number into the fucking direcotry name, huh? or just put that into a subdirectory!? And symlink that shit? Naa, symlinks are too radical for Windows.

I guess we have no choice but to continue splashing like a ball of paint on the Windows max path length barrier. (Or use UNC paths!)

Or put a new lookup mechanism into Node, that's not complete bollocks.

20

u/lorderunion May 30 '17

They fixed that nested node_modules/ issue back in v4 IIRC.

17

u/gearvOsh May 30 '17

Actually was v3.

3

u/Pas__ May 31 '17

Fixed! Unless you have collisions! Then that still gets nested.

Better than what it was? Yes. Somehow ruby gems works on the same platforms flawlessly? Yes.

But we're talking about NodeJS, so it must be the JS curse!

12

u/gearvOsh May 30 '17

NPM v3 flattens node_modules unless theres a major version collision in which point it will nest. This is no longer an issue.

1

u/Sarcastinator May 31 '17

It still nests... And I still end up with paths larger than 260 characters. Why do they nest at all?

5

u/gearvOsh May 31 '17

Because major versions would collide with each other causing backwards incompatibilities.

You seem to be doing something wrong.

-2

u/Sarcastinator May 31 '17

And what exactly does that have to do with nesting?

5

u/gearvOsh May 31 '17

That's exactly why nesting exists?

Because if foo requires baz v3, but bar requires baz v2, we can't have both versions in the root node_modules/baz path, so one of the packages will be nested to not collide.

4

u/Sarcastinator May 31 '17

Why not just append the version number at the end of the package name instead? No nesting required.

1

u/gearvOsh May 31 '17

Because thats not how Node's module lookup works, nor will it probably ever.

If foo has require('baz') and bar also has require('baz'), then how does the resolver know which version to load? All it simply does is check relative to the current module, or at the node_modules root.

→ More replies (0)

2

u/TimvdLippe May 30 '17

Yarn initially shipped with symlinks to 1 global repository. E.g. all packages with their versions are stored in a global folder and every application installation then symlinks the versions it needs from that folder. However, due to issues with Mac symlinks, it was reverted. Hopefully they will bring it back soon!

1

u/Pas__ May 30 '17

Interesting, do you have information about what was the issue? (Especially surprising that the problem was OSX.)

2

u/TimvdLippe May 30 '17

This was the issue that they were discussing in: https://github.com/yarnpkg/yarn/issues/499 There were some initial issues with other Facebook tooling and later also found issues on Windows (in a VM in OS X, so I was probably mistaken that it was not directly OS X to blame). Also there are some older issues like https://github.com/yarnpkg/yarn/issues/57 for which I can not find the actual code change related to the issue.

1

u/Pas__ May 31 '17 edited May 31 '17

Thanks!

Though I'm not sure why they are considering hardlinks at all :o

28

u/ANUSBLASTER_MKII May 30 '17

They are churning through those version numbers!

44

u/Retsam19 May 30 '17

Is that a criticism? Are you worried they're going to run out of natural numbers?

34

u/ANUSBLASTER_MKII May 30 '17

Nah, just an observation. I'm just surprised a package manager has so many backward compatibility breaking changes in the space of a few years.

109

u/DarcyFitz May 30 '17

You're surprised?

Have you met web development lately? It's worse than the fashion industry.

I'd explain it, but my keyboard isn't compatible.

0

u/[deleted] May 30 '17

[deleted]

38

u/kn4rf May 30 '17

Try updating a client project you haven't worked on for half a year and watch as every package you ever touched now is deprecated. Config formats for Babel and Webpack might suddenly have changed, some dependencies have changed the name, some projects forked out into new projects under new names, other have merged together. Most of the knowledge you had have to be relearned as stuff no longer seem to work as they did.

-7

u/tomservo291 May 30 '17

yarn fixes this with its lock file, getting you consistent transitive dependencies

npm's default handling of transitive dependencies is just stupid

27

u/ScotForWhat May 30 '17 edited May 30 '17

yarn fixes this.

Isn't that exactly the problem? Another new thing to fix issues caused by the constant churn, adding to the churn itself. It's self-fulfilling by this point.

EDIT: Parent comment was edited since I replied. Previously read:

yarn fixes this.

npm's default handling of transitive dependencies is just stupid

-1

u/tomservo291 May 30 '17

Yes and no.. yarn completely replaced npm for me. Far faster, reliable and gives you consistency garauntees.

You can argue either way, but to me it's an npm replacement and not an augmentation

5

u/kn4rf May 30 '17

The problem I tried describing was one that occurs when you try to update your packages, as they constantly change interfaces, config formats and even the names of the npm packages. This is a problem with the Node-community and has nothing to do with npm vs yarn.

2

u/steveklabnik1 May 30 '17

One of the big changes in npm 5 is adding a lockfile.

9

u/iTroll_5s May 30 '17

Maybe I'm too new to be burned by it

When your CI build breaks over the weekend because someone did a breaking change in a dependency of a dependency in a patch revision and you didn't know you need a third party tool to lockdown the dependencies in npm, and there's no obvious way to see why it's failing on the build server but it's running/building fine locally because npm cached deps - you'll love it !

When they introduce random and hard to find breaking changes in minor revisions of popular packages like angular 2 you'll be thrilled you had to spend 4 hours min on it every time to diagnose and file a bug, another 4 to workaround all for perfectly valid code - to get a fix for an even bigger issue you had before.

And the best is finding 4 different library for some basic functionality such as route matching - all of which are incomplete, hard to evaluate activity, obscure source and have no tests...

node is a PHP level cesspool

3

u/[deleted] May 30 '17

I highly disagree with that. Golden age of half way decent web development processes ended right around 2010. It's been a complete shit show since and it is only getting worse.

Sure, there's now a few bandaids to automate a couple common tasks, but that's about it.

13

u/Retsam19 May 30 '17 edited May 30 '17

... if you think 2010 was a golden age, you're welcome to continue doing web-dev like it's 2010. Personally, you couldn't pay me enough to do 2010-styled web development, but you do you.

1

u/[deleted] May 30 '17

Don't worry, wasm will bring C++ to the table and all the sophisticated tools and expertise will follow.

0

u/[deleted] May 30 '17

So... what's the state-of-the-art area now?

1

u/BertnFTW May 30 '17

Service Workers maybe?

1

u/[deleted] May 30 '17

Service Workers? What's that?

3

u/BertnFTW May 31 '17

A continuous worker in javascript.
This differs from how a webpage works now. Currently if you tab out from a screen Chrome will pause that tab.
However the service worker keeps on running.

PLUS
All requests (every fetch) goes through the service worker first!

This allows you to do great things like caching requests for if you go to the website without internet, let it be (fully) functional.

It's experimental technology, but I think it will change how we create big websites in the future.

3

u/oopsforogotmypasswor May 30 '17

I'm guessing you are not that familiar with Node.js ecosystem.

3

u/jimschubert May 30 '17

Never! npm 1e18 is due next year.

1

u/Antrikshy May 30 '17

Look at Firefox and Chrome. They're about to hit the end!

22

u/shevegen May 30 '17

Hey!

PHP outright SKIPPED a full version - the new php was SO MUCH BETTER that one could skip ahead!

39

u/SobakPL May 30 '17

Well, I know it's funny, especially considering general PHP image, but this decision had some perfectly valid reasoning. The problem was that PHP 6 (version they skipped) was actually a thing. Never reached stable, has been abandoned years ago, but it did exist. Moreover, it had different feature scope - PHP 6 was all about Unicode (PHP 7 is not), some people even wrote books and articles about it.

It was agreed upon that skipping 6 entirerly will cause less confusion.

PS: I voted for PHP 6 as a name, but I wouldn't do it now.

12

u/Klathmon May 30 '17

Yeah well the PHP guys are used to being the butt of jokes, so it's no big deal.

But PHP is a damn good language and there are some really smart people working on making the runtime fast as hell and they are adding a TON of really nice features as well as working on standardization.

I just find it ironic when JS guys shit on PHP, then in the next breath defend JS against similar arguments from C/C++ guys.

4

u/midri May 30 '17

As someone that uses PHP on the daily, my only big gripe with it these days is how namespaces are implemented... I really wish I could do:

use vendor\library

and get all the class/functions in that library... In 7 you have to access each class/function/constant specifically:

use vendor\library\class;
use function vendor\library\usefulFunction;
use constant vendor\library\constantForUsefulFunction;

...

4

u/Dgc2002 May 30 '17

In 7 you can get funky with it:

use some\namespace\{ClassA, ClassB, ClassC as C};
use function some\namespace\{fn_a, fn_b, fn_c};
use const some\namespace\{ConstA, ConstB, ConstC};  

Edit: Obviously this doesn't help your stated issue, but can alleviate some pains related to it.

3

u/throwawayco111 May 30 '17

My only problem with PHP (compared to JS) is the lack of "style" and "consistency" in the standard library. But yeah, if I judge only the language both of them are pretty shitty.

4

u/SobakPL May 30 '17

My only problem with JS (compared to PHP) is the lack of the standard library :D

Sorry, I just couldn't resist. PHP's stdlib is terribly organized, the language has few more problems than that fact alone, but in a last few years whole development seems to be way more thought-out.

5

u/Klathmon May 30 '17

Because JS is so consistent in it's standard lib?

What with setTimeout returning a number, Date not even being consistent across different browsers, parseInt being a global and .toString() being a method, isNaN() being majorly different than Number.isNaN(), and more...

JS has less of a leg to stand on there!

That being said, I love both of the languages (and think that for the most part consistency in the standard lib and other things like it are mostly not important), but let's not pretend one is "better" than the other.

0

u/throwawayco111 May 30 '17

Because JS is so consistent in it's standard lib?

More consistent than PHP standard library? Yeah.

0

u/[deleted] May 30 '17

[deleted]

1

u/throwawayco111 May 30 '17

The JS standard lib is like 20 objects/functions, and it's horribly inconsistent everywhere.

Yeah, it is amazing that PHP could be worse.

PHP is inconsistent from it's PHP4 stuff...

And that stuff is still there.

-4

u/Klathmon May 30 '17

I should have known this would be like talking to a wall with throwaway in your name.

You have fun now, and don't stay up too late, your mom will be mad!

→ More replies (0)

0

u/CanIComeToYourParty May 30 '17

PHP is a damn good language

I don't normally bash PHP, but I find this statement pretty offensive. I mean, really, some people actually put lots of effort and research into developing their languages. PHP was deeply flawed from the start — it gets so astonishingly many things wrong (It might have improved some things since, but it's still not anywhere near "damn good".)

6

u/Klathmon May 30 '17 edited May 30 '17

Ah, the eevee blog!

Outdated when it was written (half the complaints on that post have an asterisk that it has already been removed... But he "doesn't care it's is an embarrassment"!), and has since been made almost entirely wrong by changes to PHP in the last 5+ years.

You can take offense at php being pretty damn good all you want, it's not going to change the fact that it is. It's a great language, with a monumental amount of force behind it being used every single day to write fantastic products that you use. It's got it's upsides and downsides like anything, but it's not broken by any means.

And while you and many others on /r/programming will keep telling me how wrong I am for enjoying the language, i'm going to keep making stuff in languages like PHP, Javascript, Go, and more and happily ignoring the non-issues that people have been telling me are going to ruin everything since I started programming. (oh no, my editor needs to autocomplete the arguments in the wrong order! Or i need to use the new API around that function instead of the old one! The humanity!)

And if yall think PHP is unrecoverable because some parameters are out of order, I'd love to see your head explode trying to use C or C++!

4

u/mardoct May 30 '17

Outdated when it was written (half the complaints on that post have an asterisk that it has already been removed... But he "doesn't care it's is an embarrassment"!), and has since been made almost entirely wrong by changes to PHP in the last 5+ years.

See, I'm sympathetic to claims that the Fractal of Bad Design isn't great (complaining that a dynamicly typed language is dynamicaly typed, for example) but simply saying it's all wrong all the way down doesn't serve any purpose because some of it is pretty objectively still true... or at least was for years after the article came out.

Things like the fun of 'mbstring' because PHP isn't really unicode by default, the php.ini system is still a mess in terms of how it can wildly alter the behaviour of a program - especially if you're adding in ini_sets on top of it, and long standing issues that were ignored, like the fact you couldn't name methods die or list or any of the other construct names until PHP7.

This are entirely genuine complaints about the language, and just because the Fractal of Bad Design has some taste-based complaints and some that were/have become outdated doesn't mean it's all wrong... and saying it is all wrong will just reinforce their original opinion because you're ignoring many genuine complaints.

1

u/Klathmon May 30 '17

Yes but even the things that were true for years after the blog post was made aren't any more now.

The blog might have one valid thing that still applies to PHP today, but pretty much all of it is outdated useless dribble. And even that one valid thing is fixed by tools which most PHP codebases use, or by standards self-imposed by the community as they push their way toward cutting out the old crap.

3

u/mardoct May 30 '17

... php,ini still exists and the mbstring/unicode deal, and that's just limiting it to things I explicitly mentioned above.

Even if you rely on convention or the like for php.ini and use libraries to provide real unicode support the fact is it's still genuine language crticism to say you have to go out of your way to do the baseline right thing in a language.

I'll go through the article again and find a few things that still are plenty valid right now - (Note I'm not saying these are all PHP exclusive issues, but all are valid reasons to criticize PHP)

  • flakiness around == and, while === is nice, the lack of >== or <== is bothersome.

  • php.ini, as well explained with the @fopen('http://example.com/not-existing-file', 'r'); example

  • Global state like the character set for mbstring can be easy to cause hard to debug bugs

  • genuinely broken functions in the standard library - two examples: json_decode returns null when it has an error, yet null is also the way to correctly decode the json string 'null', and htmlentities will return "" for invalid input, yet "" is also the valid return value for an empty string as input.

  • Inconsistent error signaling - it's as bad as C, and in fact a bit worse because it adds exceptions on top of the error values like "", null, -1, get_last_foo_error(), or whatever else. Compare to a language that consistently uses exceptions, or consistently uses special error return types, or almost anything else.

  • getting the index of a non-indexable type (like an integer) returns null and issues no warning/error

  • no real module system, you have to manually namespace and hope every 3rd party dep you pull did the same if you're hoping for a similar level of seperation of the the things you include or require as you'd get in almost any other language out there.

  • the stat cache - the on-by-default can't-disable stat cache

I just glanced over it to identify a few issues that are still valid crticisms in PHP.

That's not saying PHP is worthless, or that PHP is unable to be used productively or anything, it's just things that are entirely valid crticisms of the language. Pretending they aren't is just going to reinforce the view that PHP devs only like PHP because they're blind to its failings.

-1

u/Jukolet May 30 '17

Time will come to shit on JS, time will come...

3

u/redalastor May 30 '17

PHP 6 (version they skipped) was actually a thing

A thing that generated a ton of hype and thus it would have been a bad decision google-wise to name it that.

PHP has many fuckups but considering Google when you name things is something more language designers should pay attention to.

14

u/pezezin May 30 '17

Bitch please, IP skipped a version number way earlier than PHP :P

Well, technically there is a IPv5, but it was as much as a succes as PHP 6...

4

u/thecodingdude May 30 '17

php, angular, windows...seems to be a trend...

3

u/gschizas May 30 '17

Don't forget FreeNAS (sort of).

3

u/[deleted] May 30 '17

Don't forget node.js, didn't they skip from 0.12 to 4.0 or something?

4

u/greygatch May 30 '17

Yeah, but it was mainly due to the merging with io.js in '15:

"Named version 4.0.0 because it includes major updates from io.js version 3.0.0, the new release also contains V8 v4.5, the same version of V8 shipping with the Chrome web browser today."

3

u/[deleted] May 30 '17

I'm not saying they're wrong to do so, just that they jumped a few versions, which looks odd from the outside. They could have just done 1.0 with the io.js as there's no real reason to have node.js's version dependant on io.js, but whatever.

2

u/bluebombed May 30 '17

react.js skipped from like 0.14 to 15.

1

u/Paradox May 30 '17

I remember when Winamp did it

56

u/encepence May 30 '17

npm will now scold you if you capitalize its name. seriously it will fight you

WTF ?

14

u/Retsam19 May 30 '17

Given the lack of commit or issue reference, probably a joke.

10

u/steveklabnik1 May 30 '17

In general, npm's branding has always been lower case; it's the legal name of the company, their twitter account only uses lower case.

So TL;DR yes. It's a reference to all of that.

23

u/Jdmnd May 30 '17

Just installed 5.0.0 on Windows, tried NPM init instead of npm init, didn't do anything.

27

u/minasmorath May 30 '17

Windows cmd doesn't care about case. Bash on Windows will probably complain.

7

u/Jdmnd May 30 '17

Not sure if that counts as real Bash, but Git Bash doesn't do anything either.

9

u/minasmorath May 30 '17

God dammit Windows.

1

u/zer0t3ch May 31 '17

I'm pretty sure it's just normal bash provided by the git installer.

4

u/lkasdfjl May 30 '17

npm always has "funny" release notes

1

u/BenjiSponge May 30 '17

This is pretty common for a bunch of companies and products (including my own), but it always poses the problem... what about if it's the first word? I think npm has gone out and said "if it's the first word, it is acceptable but not encouraged to stylize it as NPM"[citation needed] , but citation needed.

0

u/oiyouyeahyou May 31 '17

It's because they don't want to handle capitalisation in their URLs

They are rather adverse to giving the "end-developer" any flexibility. Either through complexity-hostility or out of sheer opinion.

3

u/Kaywick May 30 '17

What benefits does yarn have that are not in this release?

1

u/hero_of_ages May 31 '17

It doesn't suck.

1

u/[deleted] May 30 '17

'yarn going to need this.

-1

u/[deleted] May 30 '17

Now it comes with more leftpads!

10

u/steveklabnik1 May 30 '17

PSA: post leftpad, npm changed their policies, so it cannot happen again.

7

u/[deleted] May 30 '17

[removed] — view removed comment

3

u/danielkza May 30 '17

More detail: the "fs" package is a non-functional package. It simply logs the word "I am fs" and exits. 

I'm not even surprised anymore.

0

u/steveklabnik1 May 30 '17

Agree 100%.

-4

u/Mgladiethor May 30 '17

Ugggghhhhhhj