next.js: Next 2.3.0 Build Errors

Failed to build on /var/folders/ys/lmdgwcfx4vv8w60w68ztzdfm0000gn/T/e219bf14-76f7-492a-b13c-545576e427fb
{ Error: ./~/react-tap-event-plugin/src/injectTapEventPlugin.js
Module not found: Error: Can't resolve 'react-dom/lib/EventPluginHub' in '/Users/tknipfer/Desktop/plate/node_modules/react-tap-event-plugin/src'
resolve 'react-dom/lib/EventPluginHub' in '/Users/tknipfer/Desktop/plate/node_modules/react-tap-event-plugin/src'
  Parsed request is a module
  using description file: /Users/tknipfer/Desktop/plate/node_modules/react-tap-event-plugin/package.json (relative path: ./src)

Running into this when doing a build with the latest next release

Note from maintainers:

Fix

next.config.js

module.exports = {
  webpack: function (c) {
    if (c.resolve.alias) {
      delete c.resolve.alias['react']
      delete c.resolve.alias['react-dom']
    }
    return c
  }
}

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 23
  • Comments: 24 (9 by maintainers)

Commits related to this issue

Most upvoted comments

@chhuang I understand that. Let me see what we can do about this. For now, we can try to remove these aliases using a custom webpack config.

// next.config.js
module.exports = {
  webpack: function (c) {
    if (c.resolve.alias) {
      delete c.resolve.alias['react']
      delete c.resolve.alias['react-dom']
    }
    return c
  }
}

EDIT: I’ve tested ^^ code and it works.

Getting a similar error when building with 2.3.1 but with different lib.

> Failed to build on /var/folders/01/62l740px2cdf7pt71c398n180000gn/T/2475d29f-f372-48ac-8179-8ef5ecefb86a
{ Error: ./~/react-addons-transition-group/index.js
Module not found: Error: Can't resolve 'react/lib/ReactTransitionGroup' in '/Users/juan/Documents/Beakyn/GSP/_labs/gsp-account-react/node_modules/react-addons-transition-group'
resolve 'react/lib/ReactTransitionGroup' in '/Users/juan/Documents/Beakyn/GSP/_labs/gsp-account-react/node_modules/react-addons-transition-group'
  Parsed request is a module
  using description file: /Users/juan/Documents/Beakyn/GSP/_labs/gsp-account-react/node_modules/react-addons-transition-group/package.json (relative path: .)
    Field 'browser' doesn't contain a valid alias configuration
...
  • This doesn’t happen on 2.2
  • Removed node_modules and reinstalled.

Thank you.

@chhuang I got the same error. wrapping the deletes with if (config.resolve.alias) allowed me to run locally, as:

    if (config.resolve.alias) {
      delete config.resolve.alias['react']
      delete config.resolve.alias['react-dom']
    }

I am able to run build and start a local server after changing next.config.js but I still cannot push up to Heroku. Is it because I customized .babelrc for Ant Design, as suggested in issues #484?

Module build failed: ReferenceError: Unknown plugin "import" specified in "/tmp/build_3209d692d315564c9241ca4818b94f49/.babelrc" at 0, attempted to resolve relative to "/tmp/build_3209d692d315564c9241ca4818b94f49"

Solved For people having the same issue as me, move babel-plugin-import from devDependencies to dependencies, because it doesn’t push up to Heroku for production otherwise.

Set start to next start -p $PORT and add "heroku-postbuild": "next build" in package.json.

@arunoda I think you forgot to change c to config in your suggestion

Thank you @arunoda. The above config fixed the issue for me.

@arunoda Thanks! I’ve put up a sample repo, running npm run build will fail:

https://github.com/chhuang/next.js/tree/master/examples/basic-css

I’m getting the same error for ReactTransitionGroup on 2.2

> Using external babel configuration
> location: "/Users/chh/Dropbox/_code/.babelrc"
> Using "webpack" config function defined in next.config.js.
> Failed to build on /var/folders/3g/36b7smhs3_90v9g_832y7r740000gn/T/357a1a0b-4117-44e8-a342-bdccfacb7004
{ Error: ./~/react-addons-css-transition-group/index.js
Module not found: Error: Can't resolve 'react/lib/ReactCSSTransitionGroup' in '/Users/chh/Dropbox/_code/node_modules/react-addons-css-transition-group'
resolve 'react/lib/ReactCSSTransitionGroup' in '/Users/chh/Dropbox/_code/node_modules/react-addons-css-transition-group'
  Parsed request is a module
  using description file: /Users/chh/Dropbox/_code/node_modules/react-addons-css-transition-group/package.json (relative path: .)
    Field 'browser' doesn't contain a valid alias configuration

Edit: sorry, I’m on 2.3.1. My build passes with 2.2