node
vscode on osx can't find node
serve https locally
Create a certificate
openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout ~/git/key.pem -out ~/git/cert.pem
Current directory:
npx http-server -S --cors -C ~/git/cert.pem -K ~/git/key.pem -o --port 3001
A specific directory:
npx http-server my-directory -S --cors -C ~/git/cert.pem -K ~/git/key.pem -o --port 3001
links
Burnt a couple of nights chasing this one. Node was throwing ETIMEDOUT AggregateError
when hitting https://api.spacetraders.io/v2
even though curl
to the same address had no issue. Turns out node attempts resolve ipv6
first, and in the case of SpaceTraders API ipv6
can be resolved but the API doesn’t support it, however, the resolution time goes over 250ms from Australia to wherever it’s hosted, throwing ETIMEDOUT
. The solution is to:
net.setDefaultAutoSelectFamilyAttemptTimeout(500)
Web Development Environment on Specified Version of NodeJS, with Nix
A guide on using nix-shell to manage multiple NodeJS versions in a development environment. Demonstrates how to create shell.nix configurations to switch between different NodeJS versions including legacy versions not packaged in nixpkgs.