The Complete Developer

A bit of a change of direction today. As part of my work I use stuff like node but I’ve just picked up bits and bobs along the way. So today I’m going to work through the book The Complete Developer and learn it all a bit more formally. This also helps with some new stuff I might need to do for a new project we are quoting for.

## Node.js

npm – node package manager

# install the latest LTS version with brew
brew install node@20
# Make it the default node on my system
echo 'export PATH="/opt/homebrew/opt/node@20/bin:$PATH"' >> ~/.zshrc
# Create and initialise a new project in a directory
mkdir new_project
cd new_project
npm init
# Install a particular package and version of package in project
npm install express@4.18.2
# Install a particular package for development purposes only 
npm install --save-dev karma@5.0.0
# Fix audit issues
npm audit fix
# Fix audit issues potentially breaking 
npm audit fix --force 
# Update all packages 
npm update
# Prune / Clean up the node_modules directory
npm prune

npx – node package execute. Execute a node package without installing

npx jsonlint package.json

Simple Express Server

const express = require('express');
const server = express();
const port = 3000;

server.get('/hello', function(req, res) {
    res.send('Hello World!');
    console.log("Bingo");
    console.log("Bongo");
});

server.listen(port, function () {
    console.log('Listening n ' + port);
});

Leave a Reply

Your email address will not be published. Required fields are marked *