在 Linux 上運行 nodemon 的問題

在 Linux 上運行 nodemon 的問題

我正在運行 linux mint 19.2 和 windows 雙啟動。我有一個項目,其中使用 nodemon 重新啟動運行 nextjs 應用程式的節點伺服器。它在 Windows 上運行得很好,但在 Linux 上有一些問題。

首先,當我關閉整合終端或 vscode 終端機時,nodemon 進程不會終止。因此,當我再次打開終端或 vscode 後嘗試重新啟動應用程式時,連接埠 3000 上仍然有一個進程正在運行,因此我必須終止該進程才能再次啟動伺服器。

下一個問題是,當我編輯並儲存檔案時,伺服器嘗試重新啟動,但隨後出現錯誤,表示不存在此類檔案。我使用已安裝儲存磁碟機上的文件,但我不知道為什麼會發生這種情況。這是非常令人沮喪的。

這是我得到的錯誤

[nodemon] restarting due to changes...
[nodemon] starting `node app.js`
(node:3440) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, rmdir '/media/steveK/Storage Drive/Web Pages/React Apps/Full Stack/project/.next/cache/next-babel-loader'
(node:3440) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:3440) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[nodemon] clean exit - waiting for changes before restart

這是app.js

const express = require('express');
const next = require('next');
const PORT = process.env.PORT || 3000;
const dev = process.env.NODE_DEV !== 'production';
const nextApp = next({ dev });
const handle = nextApp.getRequestHandler();
const app = express();

nextApp.prepare().then(() => {
  app.get('*', (req, res) => {
    return handle(req, res);
  });

  app.listen(PORT, err => {
    if (err) throw err;
    console.log(`ready at http://localhost:${PORT}`);
  });
});

我嘗試過使用nodemon -L app.js,但這也沒有幫助。

還有其他人遇到過在 Linux 上運行 nodemon 的問題嗎?如果是這樣,也許你可以告訴我如何解決這個問題。

相關內容