Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Drop Node.js 16 support

License

Notifications You must be signed in to change notification settings

tshemsedinov/Drop-Nodejs16

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 

Repository files navigation

Drop Node.js 16 support in your projects

  • Now: October 2023, we have Node.js 18.18.0 LTS and 20.7.0 (current)
  • Going to drop Node.js 16 support before its end-of-file 2023-09-11 in Metarhia codebase, all projects, and course examples
  • Now we can rely on Node.js 18.18.0 capabilities
  • See release schedule: github.com/nodejs/release#release-schedule

Important notes

Refactoring checklist as of October 2023

  • Due to the move from npm v9 or later version, convert package_lock.json to lockfileVersion 3 by command: npm i --lockfile-version 3
  • Run your project with flag --pending-deprecation to see deprecation warnings and then with flag --throw-deprecation to exit with non-zero on deprecated API calls
  • Use native Fetch API instead of polyfill like undici or node-fetch. Now you can avoid axios and request() from node:http
  • You can use Web Streams API to be compatible with browser API in server-side rendering or so
  • Use Buffer method .subarray(start, end) instead of deprecated .slice(start, end): see Buffer docs
  • Stop using deprecated url.parse: see DEP0169 docs
  • Stop using deprecated Thenable in streams: see DEP0157 docs
  • Use http events: dropRequest and drop: see http docs
  • Use server.closeAllConnections() and server.closeIdleConnections(): see http docs
  • Use module.isBuiltin(moduleName): see module docs
  • Now we can use new V8 features:
  • Use promise-based node:readline API, example: const name = await rl.question('Name:'); and new methods: clearLine, commit and rollback, cursorTo, moveCursor, class Interface
  • Do not use node:async_hooks API like createHook and AsyncHook as non-stable, except stable classes AsyncLocalStorage and AsyncResource, see docs in a separate article "async context tracking"

Explore new features

Note that you can't freely use

Use node.js features instead of dependencies

  • Use native Fetch API instead of npm modules undici, request, axios, node-fetch
  • See previous recommendations for removing third-party dependencies in favour of node.js internal modules

Related links

About

Drop Node.js 16 support

Resources

License

Stars

Watchers

Forks