"服务器没有在端口 3000 上监听",但应用程序正在运行。
This is sort of similar to this issue and this issue as well as this issue. This is on a fresh setup as detailed here.
Environment
Node Version: v8.16.0, OS: Arch Linux, npm version : 6.9.0.
Setting up (server.js)
The default template comes with the following:
import sirv from 'sirv';
import polka from 'polka';
import compression from 'compression';
import * as sapper from '@sapper/server';
const { PORT, NODE_ENV } = process.env;
const dev = NODE_ENV === 'development';
polka() // You can also use Express
.use(
compression({ threshold: 0 }),
sirv('static', { dev }),
sapper.middleware()
)
.listen(PORT, err => {
if (err) console.log('error', err);
}); Then running npm install
Running
export HOST=127.0.0.1 PORT=3000
npm run build
npm run dev you get the following error
thebeachmaster@127 ~/test/svelte/hellosvelte npm run dev ✔ 7070 10:50:04
> [email protected] dev /home/thebeachmaster/test/svelte/hellosvelte
> sapper dev
✔ server (995ms)
✔ client (998ms)
✔ service worker (24ms)
> Server is not listening on port 3000 I went and checked if there was any process listening on port 3000
lsof -i :3000 | grep LISTEN only to find that a node process was ...
thebeachmaster@thebeachmaster ~/test/svelte/hellosvelte lsof -i :3000 | grep LISTEN 1|1 ↵ 7073 10:52:10
node 314 thebeachmaster 18u IPv6 382263 0t0 TCP *:hbci (LISTEN)
thebeachmaster@thebeachmaster ~/test/svelte/hellosvelte as seen here when I opened the browser...
The problem
This results in live-reloading failing. Note that in my case as opposed to this comment I did not have any other process on port 3000 other than the app.
Attempts at solving
I went ahead and set PORT=3080 and rebuilt the app, only to get the same error message but now on port 3080 ... but the app is running on port 3080 on localhost with port 3000 not listening on any processes (as expected).
> [email protected] dev /home/thebeachmaster/test/svelte/hellosvelte
> sapper dev
✔ server (959ms)
✔ client (962ms)
✔ service worker (22ms)
> Server is not
…内容来源: sveltejs/sapper