I have installed npm express and serve-flavicon, they are present in npm ls
and npm ls --global
but I'm still getting Error: Most middleware (like favicon) is no longer bundled with Express and must be installed separately
const https = require('https');
const fs = require('fs');
const express = require('express');
const app = express();
const favicon = require('serve-favicon');
app.use(express.static('public'));
app.use(express.json());
app.use(express.favicon('public/favicon.ico'));
const options = {
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
};
https.createServer(options, app).listen(8000);
CodePudding user response:
Try using what you imported.
app.use(favicon('public/favicon.ico'));