This is how I initialize a Node.js project:
Initialize a new Node.js project using pnpm:
pnpm init --init-type=module --init-package-managerIf the project is not going to be open source, remove the default
licensefield frompackage.json:pnpm pkg delete licenseInstall TypeScript and types for Node.js:
pnpm add -D typescript @types/node@24.x @tsconfig/node24Set up
tsconfig.jsonfile (more info):cat > tsconfig.json <<'EOF' { "extends": "@tsconfig/node24/tsconfig.json", "compilerOptions": { "verbatimModuleSyntax": true, "allowImportingTsExtensions": true, "noEmit": true } } EOFAdd
.gitignore:wget -O .gitignore https://raw.githubusercontent.com/github/gitignore/refs/heads/main/Node.gitignoreAdd
nodescript to let me usepnpm nodecommand to run Node.js with TypeScript support:pnpm pkg set scripts.node="node --experimental-transform-types"