Skip to content

[Bug]: Error: Cannot find module 'follow-redirects' #1834

Closed
@elliottsj

Description

@elliottsj

Summary

This error page is rendered upon visiting our app:

image

Runtime.ImportModuleError - Error: Cannot find module 'follow-redirects' Require stack: - /var/task/apps/dashboard/.netlify/functions-internal/___netlify-handler/handlerUtils.js - /var/task/apps/dashboard/.netlify/functions-internal/___netlify-handler/___netlify-handler.js - /var/task/___netlify-handler.js - /var/runtime/index.mjs

Stack trace:

Runtime.ImportModuleError: Error: Cannot find module 'follow-redirects'
Require stack:
- /var/task/apps/dashboard/.netlify/functions-internal/___netlify-handler/handlerUtils.js
- /var/task/apps/dashboard/.netlify/functions-internal/___netlify-handler/___netlify-handler.js
- /var/task/___netlify-handler.js
- /var/runtime/index.mjs
    at _loadUserApp (file:///var/runtime/index.mjs:1000:17)
    at async Object.UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1035:21)
    at async start (file:///var/runtime/index.mjs:1200:23)
    at async file:///var/runtime/index.mjs:1206:1

Netlify internal ID: 01GKMNY9325XC365GG3KHDAQNX.

Steps to reproduce

Use pnpm and deploy a site using the Netlify CLI. The command we are using is:

netlify deploy --build --prod --auth $NETLIFY_AUTH_TOKEN --site $DASHBOARD_NETLIFY_SITE_ID

Using netlify-cli@12.0.10 and @netlify/plugin-nextjs@4.29.3.

A link to a reproduction repository

No response

Next Runtime version

4.29.3

More information about your build

  • I am building using the CLI
  • I am building using file-based configuration (netlify.toml)

What OS are you using?

Mac OS

Your netlify.toml file

`netlify.toml`
[build]
  command = "pnpm run build"

[build.environment]
  NETLIFY_USE_PNPM = "true"
  NODE_VERSION = "16.18.0"

[[plugins]]
package = "@netlify/plugin-nextjs"

[[headers]]
  for = "/*"
  [headers.values]
    X-Frame-Options = "DENY"
    Strict-Transport-Security = "max-age=31536000; includeSubDomains;"
    X-Content-Type-Options = "nosniff"
    Content-Security-Policy = "object-src 'none'; base-uri 'none';"

Your public/_redirects file

`_redirects`
# Paste content of your `_redirects` file here

Your next.config.js file

`next.config.js`
import { getCommonEnvVars } from '@cohere-ai/utils/nextConfig.mjs';
import { PHASE_PRODUCTION_BUILD, PHASE_PRODUCTION_SERVER } from 'next/constants.js';

import nextTranspileModules from 'next-transpile-modules';
const withTM = nextTranspileModules([
  '@cohere-ai/ui',
  '@cohere-ai/blobheart-client',
  '@cohere-ai/finetune-client',
  '@cohere-ai/utils',
  '@cohere-ai/platform-components',
]);

const getNextConfig = (phase) => {
  if (phase === PHASE_PRODUCTION_BUILD || phase === PHASE_PRODUCTION_SERVER) {
    console.info('Next.js environment variables:', getCommonEnvVars(process.env));
  }

  return withTM({
    reactStrictMode: true,
    async redirects() {
      return [
        {
          source: '/confirm-email',
          destination: '/welcome/confirm-email',
          permanent: true,
        },
        {
          source: '/login',
          destination: '/welcome/login',
          permanent: true,
        },
        {
          source: '/register',
          destination: '/welcome/register',
          permanent: true,
        },
        {
          source: '/terms-of-use',
          destination: 'https://cohere.ai/terms-of-use',
          permanent: true,
        },
        {
          source: '/privacy',
          destination: 'https://cohere.ai/privacy',
          permanent: true,
        },
        {
          source: '/finetune/:path*',
          destination: '/models/custom/:path*',
          permanent: true,
        },
      ];
    },
  });
};

export default getNextConfig;

Builds logs (or link to your logs)

Build logs
# Paste logs here

Function logs

Function logs
Dec 6, 04:58:57 PM: 2022-12-06T21:58:57.636Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'follow-redirects'\nRequire stack:\n- /var/task/apps/dashboard/.netlify/functions-internal/___netlify-handler/handlerUtils.js\n- /var/task/apps/dashboard/.netlify/functions-internal/___netlify-handler/___netlify-handler.js\n- /var/task/___netlify-handler.js\n- /var/runtime/index.mjs","stack":["Runtime.ImportModuleError: Error: Cannot find module 'follow-redirects'","Require stack:","- /var/task/apps/dashboard/.netlify/functions-internal/___netlify-handler/handlerUtils.js","- /var/task/apps/dashboard/.netlify/functions-internal/___netlify-handler/___netlify-handler.js","- /var/task/___netlify-handler.js","- /var/runtime/index.mjs","    at _loadUserApp (file:///var/runtime/index.mjs:1000:17)","    at async Object.UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1035:21)","    at async start (file:///var/runtime/index.mjs:1200:23)","    at async file:///var/runtime/index.mjs:1206:1"]}Dec 6, 04:58:57 PM: Unknown application error occurred
Runtime.ImportModuleError

.next JSON files

generated .next JSON files
# Paste file contents here. Please check there isn't any private info in them
# You can either build locally, or download the deploy from Netlify by clicking the arrow next to the deploy time.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions