Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: require is not a function when importing an npm module in a file within the api folder #7933

Closed
jeremytenjo opened this issue Jul 12, 2019 · 6 comments · Fixed by #8246
Milestone

Comments

@jeremytenjo
Copy link

Bug report

Describe the bug

When deployed I get a TypeError: require is not a function error when importing npm module in api/allMovies.js. It works locally but not when deployed.

To Reproduce

  1. clone https://github.com/tenjojeremy/test-nextjs-simple
  2. run yarn
  3. run yarn start
  4. open localhost: 3000
  5. You should see movie posters as expected
  6. Deploy site
  7. open deployed site url
  8. you will see Internal Server Error
  9. logs will show error log:

Screen Shot 2019-07-11 at 10 31 52 AM

Expected behavior

On prod site, movies should be fetched and appear on screen on initial load

Additional context

Related to #7850

Thank you

@timneutkens
Copy link
Member

Did you install 9.0.1?

@jeremytenjo
Copy link
Author

jeremytenjo commented Jul 12, 2019

Hi @timneutkens, I upgraded to 9.0.1 and I still get Internal Server Error but now the console shows a different error message:

Screen Shot 2019-07-12 at 3 11 28 PM

The error only happens on a deployed site.

@ritz078
Copy link

ritz078 commented Jul 16, 2019

Getting the same error for a normal page component.

@Timer
Copy link
Member

Timer commented Jul 16, 2019

This is a duplicate of #7758 now -- you're looking for a file that's no longer available.

@timneutkens
Copy link
Member

Let's close this in favor of #7758 then.

@Timer Timer added this to the 9.0.4 milestone Aug 8, 2019
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants