【问题标题】:Found the error when I deploy the next.js app in cPannal在 cPanal 中部署 next.js 应用时发现错误
【发布时间】:2022-09-30 03:19:58
【问题描述】:

我想在 cPanel 中部署我的 next.js 应用程序。我按照所有步骤操作,但在stderr.log 文件中收到错误。错误是

internal/modules/cjs/loader.js:905
  throw err;
  ^

Error: Cannot find module \'next\'
Require stack:
- /home/yourhikf/dev.yourguide.pk/server.js
- /usr/local/lsws/fcgi-bin/lsnode.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (/home/yourhikf/dev.yourguide.pk/server.js:4:14)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19) {
  code: \'MODULE_NOT_FOUND\',
  requireStack: [
    \'/home/yourhikf/dev.yourguide.pk/server.js\',
    \'/usr/local/lsws/fcgi-bin/lsnode.js\'
  ]
}

这是我要加载已部署站点时记录的错误。 package.json 文件有以下包

{
  \"name\": \"yourguide-next-frontend\",
  \"version\": \"0.1.0\",
  \"private\": true,
  \"scripts\": {
    \"dev\": \"node server.js\",
    \"build\": \"next build\",
    \"start\": \"NODE_ENV=production node server.js\"
  },
  \"dependencies\": {
    \"@emotion/react\": \"^11.9.3\",
    \"@emotion/styled\": \"^11.9.3\",
    \"@mui/material\": \"^5.9.2\",
    \"@tinymce/tinymce-react\": \"^4.2.0\",
    \"cookies\": \"^0.8.0\",
    \"js-cookie\": \"^3.0.1\",
    \"next\": \"12.2.3\",
    \"react\": \"18.2.0\",
    \"react-bootstrap\": \"^2.4.0\",
    \"react-dom\": \"18.2.0\",
    \"tinymce\": \"^6.1.2\"
  },
  \"devDependencies\": {
    \"eslint\": \"8.20.0\",
    \"eslint-config-next\": \"12.2.3\"
  }
}

我无法解决问题请告诉我我的问题的解决方案。

    标签: deployment next.js cpanel


    【解决方案1】:

    我通过在终端中输入以下命令来解决它:

    • npm 更新
    • npm 安装

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-05
      • 2021-11-20
      • 1970-01-01
      • 2021-10-01
      • 2021-08-07
      • 1970-01-01
      • 1970-01-01
      • 2021-05-14
      相关资源
      最近更新 更多