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

"next build" works locally but fails in "now" in latest Next (6.1.1) #4832

Closed
trevordmiller opened this issue Jul 24, 2018 · 7 comments
Closed

Comments

@trevordmiller
Copy link
Contributor

trevordmiller commented Jul 24, 2018

Bug report

Describe the bug

I'm not sure where to put this - if it's related to next, now, or mdx. But when I run next build locally, it works just fine. When I run now and now runs next build it errors out. I've confirmed I'm using the same Node version locally that is used by now (8.11.3). I've got a package-lock.json - so in theory the build in now should be the same as local...

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. See package.json
  2. Not sure why next build (npm run build) locally would be different than the next build in now

Expected behavior

next build works the same locally as it does in now.

Screenshots

Local:

next-build-local

In Now

next-build-now

Errors with Cannot find module 'remark-highlight.js'.

System information

  • OS: macOS
  • Version of Next.js: 6.1.1
  • Version of Node: 8.11.3 both local and in now
  • Version of npm: 6.2.0 local, not sure about in now as it doesn't show it
@timneutkens
Copy link
Member

Looks like the module wasn't installed, so I'm pretty sure it's not related to Next.js. I've asked @TooTallNate to check this issue.

@trevordmiller
Copy link
Contributor Author

trevordmiller commented Jul 24, 2018

I tried with a fresh package-lock.json (rm package-lock.json && rm -rf node_modules && npm install) and it's still working locally but not when in now. So it seems something is different with either next or now than what is in my source code. To be clear, running npm run build (next build), then npm run start (next start) works locally but fails when running now.

@trevordmiller
Copy link
Contributor Author

Downgraded to working versions + Next 5: https://github.com/trevordmiller/trevordmiller-website/commit/c32f83263418084e60d13a16c39314270443f3c8

I'm going to wait until Babel 7 is stable before trying to upgrade to Next 6 again.

@timneutkens
Copy link
Member

timneutkens commented Jul 30, 2018

I'm 99% sure it's not related to babel being on beta. Also 95% sure this is unrelated to Next.js.

I can't clone your repository, on my internet connection it takes ~2 hours.

@trevordmiller
Copy link
Contributor Author

trevordmiller commented Jul 31, 2018

Did some more digging and figured out the errors I was seeing; it seems that new versions of Next.js now require devDependencies used by next to be dependencies (when using a dynamic server instead of a static export). So I had to move the dependencies in next.config.js and .baberc to be production dependencies. It seems some of the Zeit docs are inconsistent with this; a few examples:

@timneutkens
Copy link
Member

https://github.com/zeit/next-plugins/tree/master/packages/next-mdx#installation

Seems like the plugin docs are consistent, I guess we have to change the MDX docs to say to use the next-mdx plugin instead.

now require devDependencies used by next to be dependencies

This seems highly unlikely. Which devdeps?

@trevordmiller
Copy link
Contributor Author

trevordmiller commented Aug 1, 2018

Per mdx-js/mdx#128 and the related mdx-js/mdx#131, I had @mdx-js/mdx, @mdx-js/loader, and remark-highlight.js as devDependencies (--save-dev). Converting them to dependencies (--save) fixed the errors mentioned in this issue. Feel free to try it yourself. Seems to only apply when you have a custom .babelrc and next.config.js.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants