15 ms·
Node.js 15.0
- kjaer 6y agoWith the addition of workspaces and yarn.lock support to npm 7, are there still reasons to use yarn over npm?
- BillinghamJ 6y agoAnd interestingly, Yarn 2 actually goes quite a long way off what a lot of Node users wanted from it originally (at least we have no interest in moving to it). If you just use "yarn" as you'd think of it, you are probably still using Yarn 1, so I guess it's being thought of as a different parallel project
- imedadel 6y agoFrom https://blog.npmjs.org/post/621733939456933888/npm-v7-series-why-keep-package-lockjson https://blog.npmjs.org/post/621733939456933888/npm-v7-series... > The package-lock.json file is not only useful for ensuring deterministically reproducible builds. We also lean on it to track and store package metadata, saving considerably on package.json reads and requests to the registry. Since the yarn.lock file is so limited, it doesn’t have the metadata that we need to load on a regular basis. So I guess there are some performance benefits with npm 7 compared to Yarn 1?
- wayneftw 6y agoYarn v1 does caching - https://classic.yarnpkg.com/en/docs/cli/cache/ https://classic.yarnpkg.com/en/docs/cli/cache/
- patwolf 6y agoI was happy when yarn first came onto the scene and gave npm the kick in the butt it needed to improve. Now I wish yarn could be deprecated and we could go back to a single package manager. There's unfortunately segmentation in different areas around package managers, e.g. electron seems to prefer yarn. And for package maintainers there's extra overhead to document and test installation with both npm and yarn.
- chrisweekly 6y agoI hear you, but things are not really moving in that direction, because it's not that simple. The closer you look into what they do and how, the clearer it becomes that [npm7 vs yarn1 vs yarn2 vs pnpm] is the current set of legit choices, for various reasons.
- arxpoetica 6y agoNo. Use pnpm (and Volta js) instead.
- keb_ 6y agoI've been considering switching to pnpm for political reasons since using open source projects that are ultimately at the mercy of big corps (npm > Microsoft, yarn > Facebook) makes me slightly uneasy. But I'm hesitant to because pnpm seems so new. Have you encountered any regularly occurring issues or headaches regarding pnpm?
- dstaley 6y agoFWIW yarn v2 isn't affiliated with Facebook. The lead maintainer is a Datadog employee, but the project isn't at the mercy of any company.
- keb_ 6y agoThank you. I was not aware of this. Also, last I heard transitioning from yarn v1 to v2 was not straightforward. Do you know if this is still the case?
- acemarke 6y agoFWIW, I recently tried a branch where I migrated our existing repo from Yarn v1 to v2. The immediate issues I ran into were lack of Yarn v2 support for some features critical for internal enterprise usage: no support for the `strictSsl` / `caFile` config options from NPM / Yarn v1, and an inability to read lockfile URLs that were pointing to an internal NexusRepository instance for proxying NPM package installation. Both issues were resolved very quickly by the Yarn team. I then ran into a problem where the post-install build steps could not run in a locked-down corporate security environment, and that issue was also addressed very quickly, with the Yarn team putting up a PR that tried different process launching approaches and iterating until one worked for me. Having sorted out those issues, I was able to move on to actually following the steps in the Yarn v2 migration guide [0]. The steps worked basically as advertised. The `@yarnpkg/doctor` tool identified several places where we were relying on imports that hadn't been strictly declared, so I fixed those. Starting up the app caused some thrown errors as other non-declared imports were hit, so I kept iterating on fixing those. I also used the `@yarnpkg/pnpify --vscode` option to generate some kind of settings file for VS Code, and added the suggested "zip file system" extension to VS Code. That allowed me to right-click a library TS type, "Go to Definition", and show a file that was still packed in a package tarball. I had to switch off to other tasks and haven't had time to go back and finish trying out the migration. But, parts of our codebase were running correctly, and it looked like I just needed to finish out the process of checking for any remaining non-declared dependencies. Can't vouch for how this would work out in production or a larger build setup, but things looked promising overall. [0] https://yarnpkg.com/advanced/migration https://yarnpkg.com/advanced/migration
- crubier 6y agoYarn v2 PnP is simply a lifesaver if you have a medium+ sized monorepo. We have a monorepo with 180 packages here. Without pnp, it takes 1h+ just to npm install any new third party package in any local package, it’s a joke. With pnp it takes 18s. So yes, from my point of view NPM is completely inadequate for any serious JS codebase.
- georgyo 6y agoCannot figure out why you are being down voted. YarnV1 and NPM are horrible if you have a large dependency tree. YarnV2 was the first time I enjoyed the package manager.
- 411111111111111 6y agoLikely because he indirectly said that projects using less then 180 dependencies aren't serious.
- romanoderoma 6y agocould it be that in some languages (like my language for example) serious is kinda of a synonym for large? I've been downvoted at times for using it to mean exactly that, but I can't help it after more than 40 years of thinking in a language different from English.
- crubier 6y agoBy serious I meant large indeed, I’m not a native speaker. I have some serious projects that have less than 180 packages too aha. But if you start an ambitious company with a JS codebase today, start with yarn v2, you’ll save yourself some pain in the future.
- benologist 6y agoThis NPM cache been a huge time-saver for me, you can run it locally or across your whole network for a shared cache - https://guides.sonatype.com/repo3/quick-start-guides/proxying-maven-and-npm/ https://guides.sonatype.com/repo3/quick-start-guides/proxyin... https://hub.docker.com/r/sonatype/nexus/ https://hub.docker.com/r/sonatype/nexus/
- Sheepsteak 6y agoI've been trying the npm workspaces support in the last few beta and release candidate releases and it just wasn't stable enough for me. https://github.com/npm/cli/issues/1984 https://github.com/npm/cli/issues/1984
- cwp 6y agoNpm is very buggy for local dependencies - eg in a monorepo that contains node modules. That might be fixed in npm 7, but I doubt it. OTOH, yarn handles this just fine.
- moogly 6y agoAre there reasons to go back to npm? I switched back when yarn came out and haven't looked back. Been super happy with yarn. Can't say the same about npm.
- kjaer 6y agoPeople are more likely to already have npm installed and to be familiar with it. So there's an argument to be made that all else being equal, picking npm lowers the barrier to entry for new contributors. This consideration could be especially important for open source projects.
- moogly 6y agoThat's a valid point, but I don't think the barrier is particularly high. I've done the switch from npm to yarn once. It was a process measured in hours to understand the differences. It's not like Git vs Subversion or something like that.
- azangru 6y ago> Are there reasons to go back to npm? Ships with Node.
- moogly 6y agoI don't think that's very compelling, versioning-wise (it's still independently versioned). Futhermore, the official node docker images come with yarn pre-installed, and there appears to be no way to bundle in a specific npm version in source control, like you can with `yarn policies set-version` (v1). That has worked wonders for us. Before yarn we used to have problems with developers using different versions of npm on their machines/build agents, and .nvmrc/"engines" doesn't help you there other than being an "error gate". The yarn executable acting like a shim delegating to the checked-in version is brilliant for versioning (especially CI).
- kumarvvr 6y agoIs it just me or has JS programming in pure Node become too complex? And, frustratingly, the line where Node ends and frameworks begin are too blurry. This is made worse by the fact that thousands of bloggers have a node server tutorial, essentially drowning out the good ones.
- BillinghamJ 6y agoNo? Can you provide examples? On a fundamental level, Node is effectively exactly the same as it was in the v4 days etc. I also don't see how it could be possible to find the line between Node itself and frameworks ambiguous - unless the framework itself is invoking your JS files, in which case I would recommend moving to something lighter (i.e. something more designed for composition - where you call it, rather than it calling you)
- bstar77 6y agoMaybe he means that frameworks like Express have become more modular over time, which might confuse people where that line between node and framework functionality is.
- BillinghamJ 6y agoExpress really exemplifies the "composition over heavy framework" concept though - you never really hand over any control to it
- bstar77 6y agoAgreed. I've really come to love Express and the direction its gone after years of using Rails- which eventually left feeling like a prisoner to its opinionated nature.
- throw51319 6y agoI don't get Node JS. It seems like you just need to somehow know the function for a specific version of it, and stuff changes all the time. And there's not really a good auto-suggestion. You need to know the args, and it just seems "hacky". Like it's good to write something small when you know what functions you use etc... but just not stable for big stuff.
- gpmcadam 6y agoHere's a changelog instead of this weird blog post: https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V15.md#15.0.1 https://github.com/nodejs/node/blob/master/doc/changelogs/CH...
- breakingcups 6y agoWhat do you find weird about it?
- Kaze404 6y agoIt's on medium for one.
- booi 6y agomaybe more people would look at it if it were on tiktok
- highmastdon 6y agoEven though I was NEing to this comment, I feel the quality of the comments is becoming more Redditilized, which saddens me. It used to be that every comment was going into detail on what the point was instead of a sarcastic one-liner (sneer in Dutch)
- xwdv 6y agoI think the original comment illustrated the point well enough. A change log should be optimized for practicality not popularity, otherwise we end up in a hellish world where change logs get published as Instagram posts or tiktok videos.
- gpmcadam 6y agoIt was completely empty aside from the headings. It turns out that a content blocker in Safari was causing this. I have no idea why, perhaps because of some class name or ID in the HTML on Medium?
- vmception 6y agohas anyone aliased npm to run nvm first, and then run npm, passing in the arguments? or have people made nvm run when their system or terminal window starts so that they don't have to remember to do it
- aphexairlines 6y agoYou can run nvm as part of your prompt so you pick it up when you cd into a directory with an nvmrc. In your bash_profile: UPDATE_NVM='[ -e .nvmrc ] && [ v$(<.nvmrc) != $(node --version) ] && nvm use' PROMPT_COMMAND="$UPDATE_NVM; ...other prompt commands..."
- mikewhy 6y agoWe combine direnv with a .nvmrc
- jessaustin 6y agoI use "n", not "nvm". No futzing around with .bashrc, just put stuff in /usr/local as God intended. https://www.npmjs.com/package/n https://www.npmjs.com/package/n
- iaml 6y agoI use nix (nix-shell) for that, it's basically universal package and env manager. You create a config file, put it in directory, and wherever you are in that directory doing `nix-shell` will put you in correct env, not just in js. You could also script it basically however you like.
- mekster 6y agoDoes that work fine in cron and other way of invoking programmatically? Many of these version managers always simply can't be involved outside interactive shells because they require unit script to be loaded first.
- iaml 6y agoI did not need to work with this use case, but from what i understand about it, you configure cron in nixos in a declarative way and nix configures cron[0], but you will most likely see no issues with scripting it anyway, there's a whole language and it can interop with other languages [0] https://nixos.wiki/wiki/Cron https://nixos.wiki/wiki/Cron
- reidjs 6y agoThose logical assignment operators look pretty neat. I wish they went into detail about how they work and how to use them, though.
- richyliu 6y agoHere's more information on the 3 new logical assignments Logical OR assignment (||=) [1] Logical AND assignment (&&=) [2] Logical nullish assignment (??=) [3] An example for OR assignment: let a = ''; a ||= 'hello'; console.log(a); // prints 'hello' a ||= 'not this'; console.log(a); // prints 'hello' [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_OR_assignment https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... [2]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND_assignment https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... [3]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_nullish_assignment https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- gosukiwi 6y agoFinally. I missed that idiom from Ruby so much.
- joemaller1 6y agoMight save a few keystrokes here and there: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND_assignment https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_OR_assignment https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_OR_assignment https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- z3t4 6y agoCould be used for ubfuscation
- pupppet 6y agoCan Node eventually fix the problems that coaxed Ryan Dahl to move on to Deno?
- pupppet 6y agoI don't know why this is being downvoted. Ryan Dahl, the original developer of Node, moved on to build Deno.
- jtdev 6y agoIt’s being downvoted because the Node community seems to have a hard time accepting constructive criticism... which is ironically also at the core of much of what’s wrong with Node in general.
- jdlshore 6y agoConstructive criticism is specific and helpful. OP is just kvetching.
- jorisd 6y agoCan you elaborate on this? I've always felt that the Node community, and the wider JavaScript community alongside it, has always been open to and embracing of constructive criticism, whether or not it's regarding the language itself (TC39, codemods / babel transformers, TypeScript, and any language that targets (Node)JS's ecosystem), established frameworks and libraries (underscore -> lodash, moment.js -> luxon), package management (pnpm, yarn), or even governance (the io.js fork, which was later on merged back into Node) and module systems (es modules, commonjs, et cetera). Ryan's original criticisms regarding Node were totally valid, but most of them weren't really easily addressable without significant breakage or a long migration strategy, which potentially could've caused a _lot_ of issues and unclarity for many years.
- sieabahlpark 6y agoSee the issues with azer and leftpad, Jamiebuilds and lerna, and every sjw fork of node because someone said something bad. If you notice none of the forks ever got traction and Jamie got punted for his trash handling of a major project.
- avolcano 6y agoGlad to see "throw on unhandled rejections" make it into Node, finally! I can stop carting around this little bit of code I used in every Node API I wrote: process.on('unhandledRejection', (err) => { console.error(err.stack); process.exit(1); }); Had become as second-nature for me as "set -euo pipefail".
- azakai 6y agoVery happy to see this too! In Emscripten we've had to emit a handler like that by default, so that test suites don't silently ignore errors. Being able to not emit it will avoid some code size and annoyances users have had.
- rmrfrmrf 6y agoidk if you've ever run into it, but `process.exit` has been a bit of a footgun in our node apps due to broken pipes and (sometimes) async io with `console` we instead use process.on('unhandledRejection', (reason) => { throw reason; }); which, as long as you havent handled `uncaughtException`, prints the stack trace and aborts.
- andrewmcwatters 6y agoIf one were to use GitHub stars as a metric, I'm particularly interested to see that deno is catching up and in some regards surpasses Node.js' metrics. Life shows that usually one can't catch lightning in a bottle twice.
- sieabahlpark 6y agoI use and prefer node but don't star the project because I don't want to hear or see the drama. I don't care to see any updates outside of the release chain. There are plenty of people like me that don't involve themselves with the star metric. Just take a look at npm downloads and consider the difference between stars and "adoption"
- rattray 6y agoSupport for ||= and ??= is very exciting!
- phist_mcgee 6y agoGee really? I feel like this is just another set of symbols I will have to mentally parse and remember what they mean. Sometimes too much shorthand is a thing.
- 0x6c6f6c 6y agoOn the other hand, the syntax for _operation_ assignment operators are pretty well standardized though. Perform operation and save value. I'd argue every operation should have already had it's respective assignment operator to be more consistent.
- alphachloride 6y ago> You can expect new releases of Node.js 15 approximately every two-weeks, In this state, shouldn't it be Node 0.15?
- zachrip 6y agoNo? Node.js 15 is "current" - as in it is essentially the "develop branch." If you take a look at the release cycle, 14 will start LTS in a few days, and 16 will start as LTS next year in April. While in LTS they only receive security updates as well as critical bug fixes.
- alphachloride 6y agoI agree, but for the reason that going to 0.15 from 14 wouldn't make sense. I believe the master, v14.x, and v15.x branches are diverging anyways, each with their own development. They snapshot the master branch at some times into a new branch as the next master version, and do patches on that branch. So multiple branches are concurrently being developed. But the master branch, not v15.x, would be the canonical "develop branch".