Skip to content

Node.js

Misc

Installing node.js

Source: Set up your Node.js development environment with WSL 2

# Get Node version manager. Check for newer release at https://github.com/nvm-sh/nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
nvm install node  # Install the newest node
nvm install --lts # Install the current LTS version

# Set some defaults form npm init. See current settings with "npm config list | grep init"
npm set init-author-name "Mads Hvelplund"
npm set init-author-email "mads@swissarmyronin.dx"
npm set init-author-url "https://your-url.com"
npm set init-license "MIT"
npm set init-version "1.0.0"

Make sure that neither path for node and npm hit the ones installed locally by NVM!

Setup new project

Initialize a project with:

npx --yes license MIT
npx --yes gitignore node
npm init -y

# for typescript add ...
npm i typescript --save-dev
npx --yes tsc --init
echo "console.log('Hello World');" > index.ts
npm install && tsc && node index.js