# Initialize a new project (creates package.json)
npm init -y
# Install a package and save it as a dependency
npm install express
# Install a package and save it as a dev dependency
npm install --save-dev nodemon
# Install all dependencies from package.json
npm install
# Uninstall a package
npm uninstall express
# Run a script defined in package.json
npm run dev
const path = require('path');
// Join path segments together
const filePath = path.join(__dirname, 'public', 'index.html');
// Result on Linux/macOS: /path/to/project/public/index.html
// Result on Windows: C:\path\to\project\public\index.html
console.log(filePath);
// Get the base file name
console.log(path.basename(filePath)); // index.html
// Get the directory name
console.log(path.dirname(filePath)); // /path/to/project/public
// Get the extension
console.log(path.extname(filePath)); // .html