如何配置 plesk 以运行下一个 js 应用程序

问题描述

我在子域上运行最基本的下一个应用程序,由 package.json 和 pages/index.js 文件组成。我无法让应用正确响应 - 如果我调用 url,我会收到 500 内部服务器错误SyntaxError: Unexpected token <

package.json:

{
  "name": "nextapp","version": "1.0.0","description": "","main": "index.js","scripts": {
    "dev": "next -p 5004","start": "next start -p 5004","build": "next build"
  },"keywords": [],"author": "","license": "ISC","dependencies": {
    "next": "^10.0.6","react": "^17.0.1","react-dom": "^17.0.1"
  }
}

index.js:

const Index = () => (
  <div>
    <p>Hello Next.js</p>
  </div>
);
export default Index;

该应用程序已部署到 plesk 服务器。当尝试从 plesk 控制面板运行 npm install 时,会弹出一大堆警告/警告(我得到的大多数对等依赖项不是由 plesk npm install 安装的):

    npm WARN read-shrinkwrap This version of npm is compatible with lockfiLeversion@1,but package-lock.json was generated for lockfiLeversion@2. I'll try to do my best with it!
    npm WARN @next/react-refresh-utils@10.0.6 requires a peer of webpack@^4 || ^5 but none is installed. You must install peer dependencies yourself.
    npm WARN next@10.0.6 requires a peer of fibers@>= 3.1.0 but none is installed. You must install peer dependencies yourself.
    npm WARN next@10.0.6 requires a peer of node-sass@^4.0.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
    npm WARN next@10.0.6 requires a peer of sass@^1.3.0 but none is installed. You must install peer dependencies yourself.
    npm WARN nextapp@1.0.0 No description
    npm WARN nextapp@1.0.0 No repository field.
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

从终端进行 npm install 运行流畅。之后,构建命令将在 plesk 面板和终端中运行。 本地主机在启动后正在侦听 5004,正如预期的那样(使用 nmap 检查)。
(附加)Nginx 指令是:

location /  {
    proxy_pass    http://localhost:5004;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}

节点设置(在 plesk 中)指向 package.json 所在的应用程序和文档根目录。应用程序启动文件设置为 pages/index.js
一个等效的 express-server 运行没有问题。

我确信必须有一个简单的解决方案来让它运行,但我无法弄清楚。非常感谢任何帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)