簡體   English   中英

如何終止在localhost:8080(MacOS)上運行的VueJS應用程序

[英]How to kill VueJS application running on localhost:8080 (MacOS)

我的環境:MacOS Mojave

我使用它們的模板創建了一個VueJS應用程序

vue init pwa frontend
? Project name frontend
? Project short name: fewer than 12 characters to not be truncated on homescreens (default: same as name)
? Project description A Vue.js project
? Author me@myemail.com
? Vue build runtime
? Install vue-router? Yes
? Use ESLint to lint your code? No
? Setup unit tests with Karma + Mocha? No
? Setup e2e tests with Nightwatch? No

yarn
yarn dev

很好。 該頁面在localhost:8080上運行,並在ctrl-c時關閉。

然后我將其建造用於生產

yarn build

我編寫了一個快速的JS服務器,從dist /文件夾中啟動內容,以查看構建后的外觀。

const ora = require('ora')
const chalk = require('chalk');
const express = require('express');
const port = process.env.PORT || 8080;
const app = express();
const spinner = ora(chalk.yellow("Your application is starting..."));
spinner.start();

var delay = ( function() {
    var timer = 0;
    return function(callback, ms) {
        clearTimeout (timer);
        timer = setTimeout(callback, ms);
    };
})();

app.use(express.static(__dirname + "/dist/"));
app.get(/.*/, function(req, res) {
    res.sendFile(__dirname + "/dist/index.html");
});

app.listen(port);

delay(function() {
    app.use(express.static(__dirname + "/dist/"));
    app.get(/.*/, function(req, res) {
        res.sendFile(__dirname + "/dist/index.html");
    });
}, 3000);

spinner.stop();
console.log(chalk.cyan("Your application is running here: ") + ("http://localhost:8080"));

我運行服務器node server.js

但是,當我ctrl-c時,它會殺死腳本,但是應用程序仍在localhost:8080上運行

我試過sudo lsof -i tcp:8080netstat -vanp tcp | grep 8080 netstat -vanp tcp | grep 8080 ,他們都什么也沒返回。 這給我留下了以下問題:如何停止監聽8080端口?

如果有人想知道,我發現了問題所在。 我不得不去chrome://serviceworker-internalschrome://appcache-internals 我搜索localhost:8080並殺死了那些服務人員。

我希望這對接下來發生的任何人有幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM