It is 2026, I still us nvm to manage my local node installation, most of the time I just run nvm install --lts
I tried pnpm, it seems faster, but it introduces a new lock file, so I stick with npm.
To be more secure disable post install scripts in the .npmrc configuration.
save-exact=true
min-release-age=5
ignore-scripts=true
Notes on Packages
dotenv is not needed anymore, node can handle an env file with node --env-file-if-exists=file
A few other packages can be replaced:
node-fetch → use the built in fetch()
Test frameworks → node:test
chalk / kleur → util.styleText()
glob → fs.glob()
rimraf → fs.rm({ recursive: true })
mkdirp → fs.mkdir({ recursive: true })
uuid (v4) → crypto.randomUUID()
Nodemon → node can watch files for changes with —watch
Standard library has now a node: prefix so use
import fs from 'node:fs';
import path from 'node:path';
import os from 'node:os';
...knip
I love the tool knip, it highlights all unused imports, packages. With this you can do a good deep cleanup. example config knip.json
{
"entry": ["src/index.tsx"],
"project": ["src/**"],
"ignore": [
"/src/openapi/**",
],
"exclude": ["enumMembers"]
}Other Tools
check what is outdated: npx npm-check-updates -i --format group
check for critical: npm audit --audit-level=critical
start a debugger with: node --inspect index.js
Other Notes
structuredClone()to get a deep copyBigInt if your numbers are bigger than Number.MAX_SAFE_INTEGER
node can directly import a json
import data from ‘./data.json’ with { type: ‘json’ }
Frameworks
Vue.js is still a great choice.
TypeScript and node.js
During development we use tsc and node with the watch parameter, we can start them both as side by side terminal with a vscode task.
package.json
"dev:tsc": "tsc --watch --preserveWatchOutput",
"dev:node": "node --watch-path=./dist dist/index.js"TypeScript without TypeScript
TypeScript has syntax that does not exist in JavaScript, if you avoid them you don’t need the build/transpiling step. Without the special syntax you can strip the types from the .ts files and run them as JavaScript.
With tsc --erasableSyntaxOnly you can check if any TypeScript special syntax is used in the project. erasableSyntaxOnly
JavaScript with JSDoc checked by TypeScript
A JavaScript project can still use TypeScript for checking the code and catching bugs. The type information can be provided as JSDoc.
Checking JavaScript files
tsc --noEmit --allowJs --checkJs <file>
Snippets
Testing with the node standard library.
// node --test file.js
import {describe, it} from "node:test"
import assert from "node:assert"
function isEmailValid(email) {
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
}
describe("isEmailValid function", () => {
it("returns true for a valid email", () => {
assert.ok(isEmailValid("john@example.org"))
})
it("returns false for a invalid email", () => {
assert.ok(!isEmailValid("john@example"))
})
})
