Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Node.js Development in 2022

Node.js Development in 2022

Nikita Galkin

November 27, 2021
Tweet

More Decks by Nikita Galkin

Other Decks in Programming

Transcript

  1. Nikita Galkin Love and Know: ▰ How to make developers

    and business happy ▰ Technical and process debt elimination Believe that: ▰ Any problem must be solved at the right level ▰ Software is easy. People are hard ▰ A problem should be highlighted, an idea should be "sold", a solution should be demonstrated Links: Site GitHub Twitter Facebook 2
  2. Today Agenda 1. What is special about Node.js? 2. Node.js

    v16 features 3. Node.js ecosystem state 4. What to learn?
  3. // Before function wait(timeout) { return new Promise((r) => setTimeout(r,

    timeout)); } // Node.js v16 import {setTimeout as wait } from "timers/promises"; async function example() { await wait(5000); console.log('After 500ms'); } example();
  4. import { setInterval, } from 'timers/promises'; const interval = 100;

    for await (const startTime of setInterval(interval, Date.now())) { const now = Date.now(); console.log(now); if ((now - startTime) > 1000) break; }
  5. const http = require('http'); const ac = new AbortController(); const

    signal = ac.signal; http.request('https://example.org', { signal }, (res) => { /** … **/ }); // Cancel the request! ac.abort();
  6. node:net:1420 throw new ERR_SERVER_ALREADY_LISTEN(); ^ Error [ERR_SERVER_ALREADY_LISTEN]: Listen method has

    been called more than once without closing. at new NodeError (node:internal/errors:371:5) at Server.listen (node:net:1420:11) at Object.<anonymous> (/Users/example.js:10:8) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:17:47 { code: 'ERR_SERVER_ALREADY_LISTEN' }
  7. // Before npm install source-map-support // Node.js v16 node server.js

    --enable-source-maps // or use env var NODE_OPTIONS="--enable-source-maps"
  8. 1. npm install as fast as yarn 2. package-lock.json v2

    format 3. npm exec 4. workspaces 5. overrides (resolutions from yarn) are in development
  9. Running x86 vs arm64 node resulted in a ~40% improvement.

    Node.js v16 has darwin-x64 (Intel) and darwin-arm64 (Apple Silicon) builds
  10. Open Source Startups Funding • Gatsby – round B, May

    2020, 28m • Strapi – round A, may 2020, 10m • Cube Dev – round A, Jul 2021, 15.5m • Bubble – round A, Jul 2021, 100m • Apollo – round D, Aug 2021, 130m • Vercel – round D, Nov 2021, 150m
  11. Required by industry • EcmaScript & TypeScript • DevOps: CI/CD,

    IoS, 12factor • Cloud Native: one of AWS, GCP, Azure and Kubernetes • Web API: OpenAPI, GraphQL, AsyncAPI, etc
  12. Required by Business • Soft Skills (English!) • Reporting and

    analytics (Mixpanel) • Headless CMS • NoCode: use, integrate or migrate • Personalization: Internet Of Behavior