Does npx no longer do install-less run?

You can do following if you are not willing to type ‘yes’ everytime you install. npm_config_yes=true npx cowsay “hello” See this https://github.com/npm/cli/issues/2226 npx also has a –yes flag you can use to bypass the prompt: npx –yes some-npm-package This is undocumented if you run npx –help, but the documentation for this flag is hidden in … Read more

Speed up NPM install in Docker container

This method works like magic: https://blog.playmoweb.com/speed-up-your-builds-with-docker-cache-bfed14c051bf Docker has a special way of caching things for you, and apparently it’s best to use the inborn caching ability. Cannot say I completely understand how it works, but it does work. If you follow this pattern, it will work for you: FROM mhart/alpine-node:5.6.0 WORKDIR /src # Expose the … Read more

Difference between Transferred and Size columns in Mozilla Firexfox Network tab

Your express application has gzip compression enabled as indicated by the Content-Encoding: gzip header, so the response body is compressed with gzip before sending over the network. Transferred size is when compressed, and size is decompressed in the browser. Express is doing this on the fly, so even though your file is not compressed on … Read more

Typescript + Express : Type ‘typeof e’ has no compatible call signatures

You need to import the default export from express instead of the namespace (which is an object with all named exports). In your app.ts this should be all you need: // Change these import express from “express”; import bodyParser from “body-parser”; The difference is: // Namespace import import * as express from “express”; const app … Read more

How to default to returning errors as JSON instead of HTML with express?

You add custom error handling middleware – which is regular middleware but with 4 arguments instead of 3 – to the middleware stack. In this error handler you use res.status(code).send(jsonResponse) to send the json error. A simple quick example that will always send status 500 JSON errors: const bodyParser = require(‘body-parser’) const express = require(‘express’) … Read more