Не удаётся получить доступ к localhost
Я запустил сервер, а браузер мне пишет "Не удаётся подключить доступ к сайту". После этого, когда я начал выключать сервер, мне выдало в консоль:
npm ERR! code ELIFECYCLE
npm ERR! errno 3221225786
npm ERR! depositbook@1.0.0 start: `node index.js`
npm ERR! Exit status 3221225786
npm ERR!
npm ERR! Failed at the depositbook@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Admin\AppData\Roaming\npm-cache\_logs\2023-07-14T04_58_37_680Z-debug.log
js:
const https = require('https')
const fs = require('fs')
let server = https.createServer((req, res) => {
res.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'})
const stream = fs.createReadStream('./all/start.html')
stream.pipe(res)
})
const PORT = 4000
const HOST = 'localhost'
server.listen(PORT, HOST, () => {
console.log(`Сервак рабочий : https://${HOST}:${PORT}`)
})
Источник: Stack Overflow на русском