What Is New in Node.js 8?
| Category | Change |
|---|---|
| New Features | async/await natively supported (V8 5.7) |
| New Features | util.promisify() backported |
| New Features | N-API (experimental) for stable native addons |
| New Features | npm 5 bundled |
| Improvements | V8 Inspector integration promoted to stable |
| Improvements | WHATWG URL parser added to core |
| Improvements | Buffer() constructor deprecated in favor of Buffer.alloc()/Buffer.from() |
| Security | OpenSSL 1.0.2l |
async/await Natively Available -- The Biggest Change in Modern Node.js
Node.js 8 ships with V8 5.7, making async/await natively available without flags or transpilation. This is arguably the most impactful developer experience improvement in Node.js history -- switching from nested callbacks and promise chains to readable, sequential-looking async code.
// Before async/await
function getUser(id) {
return db.findOne({ id })
.then(user => permissions.load(user))
.then(perms => ({ ...user, perms }));
}
// With async/await in Node.js 8
async function getUser(id) {
const user = await db.findOne({ id });
const perms = await permissions.load(user);
return { ...user, perms };
}
V8 Inspector Stable -- Node.js Debugging in Chrome DevTools
The V8 Inspector protocol is stable in Node.js 8. Running node --inspect server.js starts the debugger endpoint. You can then open chrome://inspect in Chrome to attach, set breakpoints, inspect memory, and profile CPU -- all without extra tools.
node --inspect server.js
# or break on first line:
node --inspect-brk script.js
WHATWG URL API
Node.js 8 introduces the WHATWG URL class (the same standard as browsers). It replaces the older url.parse() with a spec-compliant implementation that handles relative URLs, search params, and unicode domains correctly.
const url = new URL('https://example.com/path?q=hello&page=2');
console.log(url.hostname); // example.com
console.log(url.searchParams.get('q')); // hello
Buffer Safety -- Buffer.alloc() Over new Buffer()
The Buffer() constructor is deprecated in Node.js 8. The replacement APIs are Buffer.alloc(size) (zero-filled), Buffer.allocUnsafe(size) (uninitialized, faster), and Buffer.from(data). The old constructor was a security risk because it could expose uninitialized memory from the heap.
FAQ
Is Node.js 8 an LTS release?
Yes. Node.js 8 (codename "Carbon") was an LTS release. Support ended December 2019.
Does async/await in Node.js 8 require Babel?
No. V8 5.7 is the first V8 version to natively implement async/await. No transpilation required for Node.js 8+ targets.
What is the performance difference between async/await and Promise chains?
In early V8 implementations async/await had some overhead. V8 6.x (Node.js 10) significantly improved this. In Node.js 8, async functions are still faster than deeply nested callbacks, but if you need maximum throughput on tight loops, profile before committing.
Does the WHATWG URL class support URL manipulation?
Yes. Properties like url.searchParams (a URLSearchParams instance) are mutable -- setting them updates the full URL string. url.searchParams.set('page', 3) modifies url.href in place.
What does npm 5 add over npm 4?
npm 5 introduced package-lock.json for deterministic dependency resolution, significantly faster installs via a parallel-fetch pipeline, and npm audit (added in npm 6, but the lock file was foundational).