Node.js Cheat Sheet
Transform, format, and optimize your data instantly with this free client-side tool.
CLI & Execution
Execute a JavaScript file
Check Node.js version
Evaluate inline script
Run with built-in watch mode (Node v18+)
Package Management (NPM)
Initialize a new package.json
Install a package and add to dependencies
Install as a development dependency
Remove a package
Run a script defined in package.json
Execute a package binary without installing globally
Globals
Directory name of current module (CommonJS)
File name of current module (CommonJS)
Current working directory
Access environment variables
Exit process with failure code
Modules
Import CommonJS module
Export CommonJS module
Import ES module (requires "type": "module" in package.json)
Export ES module
File System
Import Promise-based FS API
Read file contents
Write data to file
Append data to file
Delete a file
Create a directory
Read directory contents
Check if file/dir exists (synchronous)
Path Module
Import Path module
Join multiple path segments safely
Resolve into an absolute path
Get the filename ('bar.txt')
Get file extension ('.html')
HTTP Server
Import HTTP module
Create a simple web server
Events
Create event emitter instance
Register an event listener
Trigger an event
Child Process
Import exec from child_process
Run a shell command
Advanced
Explore advanced configurations for Nodejs
Performance tuning best practices for Nodejs
Run security checks and validation for Nodejs
🔥 Similar Tools
Explore LibraryFrequently Asked Questions
Got questions? We've got answers.