question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

next export builds, but errors in client…

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

Client side routing, navigation and routing would work.

Current Behavior

Ran next export and when I serve locally (and online) there’s a client side JavaScript error that breaks all the client side logic.

Without sourcemaps (or any other debugging tools?) I can’t work out what’s happening. Live URL: https://dkfyjniin9u60.cloudfront.net/ (see console in browser).

Not sure I can replicate as yet, as it’s larger site - pretty sure the vanilla examples work.

Context

Including the next.config.js - possibly this is factoring?

const { env } = process;
const webpack = require('webpack');

module.exports = {
  exportPathMap () {
    // we fetch our list of posts, this allow us to dynamically generate the exported pages
    const all = require('./server/lib/docs');

    // transform the list of posts into a map of pages with the pathname `/post/:id`
    const pages = all.posts.docs.reduce((pages, post) =>
      Object.assign({}, pages, {
        [`${post.url}`]: {
          page: '/_post',
          query: { slug: post.slug }
        }
      }),
    {});

    // combine the map of post pages with the home
    return Object.assign({}, pages, {
      '/': { page: '/' }
    });
  },

  webpack: function (config) {
    // this exposes everything on process.env.X
    const webpackEnv = Object.keys(env).reduce((acc, curr) => {
      acc[`process.env.${curr}`] = JSON.stringify(env[curr]);
      return acc;
    }, {});

    config.plugins.push(new webpack.DefinePlugin(webpackEnv));

    return config;
  }
};

Your Environment

Tech Version
next 3.0.1-beta.13
node 8.1.0
OS Mac 10.10.3 (14D136)
browser Chrome Version 61.0.3156.0 (Official Build) canary (64-bit)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
CodeOttercommented, Apr 13, 2018

you’re only trying to hurt people,

Since we’re now allowed to play psychologist and impose what we think people are trying to do, let’s point out a few examples on how this project has handled the sourcemaps problem throughout its history:

Here’s Next.js justifying why sourcemaps are low priority despite every JS project on Earth needing them

#137

How to enable Sourcemaps? Unfortunately, It’s not supported for now. It’s just low priority

Here’s Next.js questioning why anyone would ever want sourcemaps on production, as if the coder asking the question is violating some secret agreement for daring to want a reliable stack trace for production bugs

#1903

Is it possible to generate/serve separate source map files in production? But @Rowno exposing source maps into production is not a pretty good idea.

Here’s a disobedient Next.js user baffled on how the project doesn’t have reliable sourcemaps. Seems like he’s trying to hurt people, too.

#2990

I have this problem too and I’m surprised more developers are not complaining about this issue. Is there a workaround for this?

And finally, my personal favorite, here’s one where Next.js is, once again, justifying why it doesn’t feel the need to warn users up front that sourcemaps are in a permanently EXPERIMENTAL state and cannot be relied upon. The reasoning? Oh, well, tone policing matters more than issuing clear and concise warnings about the project’s feature set:

#2562

you’re only trying to hurt people,

And before you continue to play the “Open Source” plausible deniability card, open source means being honest about what it is you are doing. I hope you approve of my PR to make people aware of Next.js’s historical policy regarding sourcemaps before they decide to use it.

https://github.com/CodeOtter/next.js/pull/1

5reactions
timneutkenscommented, Apr 13, 2018

Next 5.1 has better support for sourcemaps as I said before, just use next-sourcemaps, we worked on fixing those issues together with @ptomasroos.

Again please provide a reproducible example of what isn’t working for your particular case so I can have a look into it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

next export builds, but errors in client… · Issue #2562 - GitHub
Ran next export and when I serve locally (and online) there's a client side JavaScript error that breaks all the client side logic....
Read more >
Next.js build error: Export encountered errors on following paths
I found onething, when i assigned a static value and it was built, but I never wanted it. const routine1 = {id :1,...
Read more >
Advanced Features: Static HTML Export | Next.js
Export your Next.js app to static HTML, and run it standalone without the need of a Node.js server.
Read more >
Understanding static HTML export in Next.js - LogRocket Blog
Learn why you should use HTML static exporting from a Next.js application, HTML static export use cases, and how you can do it...
Read more >
Static HTML Export with i18n compatibility in Next.js
BUT, you may have heard about this: ... This happens if you're using the internationalized routing feature and are trying to generate a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found