serverless-next.js icon indicating copy to clipboard operation
serverless-next.js copied to clipboard

503 ERROR The request could not be satisfie - Cannot find module 'next/dist/compiled/node-fetch'\

Open anonymouscatcher opened this issue 2 years ago • 3 comments

It seems 503 is a pretty usual error, In my case I get this one:

Screenshots/Code/Configuration/Logs

my-app:
  component: '@sls-next/[email protected]'
  inputs:
    useServerlessTraceTarget: true
    nextConfigDir: ./src1
    nextDistDir: ./src1
    build:
      cmd: ../node_modules/.bin/next
{
  "errorType": "Error",
  "errorMessage": "Cannot find module 'next/dist/compiled/node-fetch'\nRequire stack:\n- /var/task/pages/_error.js\n- /var/task/default-handler-0a0dc009.js\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
  "trace": [
    "Error: Cannot find module 'next/dist/compiled/node-fetch'",
    "Require stack:",
    "- /var/task/pages/_error.js",
    "- /var/task/default-handler-0a0dc009.js",
    "- /var/task/index.js",
    "- /var/runtime/UserFunction.js",
    "- /var/runtime/index.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:101:18)",
    "    at Object.9371 (/var/task/pages/_error.js:4563:18)",
    "    at __webpack_require__ (/var/task/webpack-runtime.js:25:42)",
    "    at Object.3634 (/var/task/pages/_error.js:4202:42)",
    "    at __webpack_require__ (/var/task/webpack-runtime.js:25:42)",
    "    at Object.4336 (/var/task/pages/_error.js:34:94)",
    "    at __webpack_require__ (/var/task/webpack-runtime.js:25:42)"
  ]
}

Versions

  • OS/Environment:
  • @sls-next/serverless-component version: 3.7.0
  • Next.js version: 12.0.6

anonymouscatcher avatar Jun 20 '22 17:06 anonymouscatcher

After investigation it seems node_modules is not part of the .zip file, is there any solution to force include node_modules in the app with having nextDistDir?

anonymouscatcher avatar Jun 22 '22 14:06 anonymouscatcher

any solutions?

Roee-Tsur avatar Sep 16 '22 21:09 Roee-Tsur