mars/heroku-nextjs

Can't resolve 'react'

tgoldenberg opened this issue · 1 comments

Not sure why it would cause this error on build. Providing the build log below. Happy to provide any other details as well.

note: logs are abbreviated to fit Github's max char limit

-----> Node.js app detected
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NPM_CONFIG_PRODUCTION=true
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
-----> Installing binaries
       engines.node (package.json):  6.9.x
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 6.9.x via semver.io...
       Downloading and installing node 6.9.5...
       Using default npm version: 3.10.10
-----> Restoring cache
       Skipping cache restore (new runtime signature)
-----> Building dependencies
       Installing node modules (package.json)
       
       > node-sass@4.5.0 install /tmp/build_473136e9feee81831d3b2c2a9f63617d/node_modules/node-sass
       > node scripts/install.js
       
       Downloading binary from https://github.com/sass/node-sass/releases/download/v4.5.0/linux-x64-48_binding.node
       Download complete
       Binary saved to /tmp/build_473136e9feee81831d3b2c2a9f63617d/node_modules/node-sass/vendor/linux-x64-48/binding.node
       Caching binary to /app/.npm/node-sass/4.5.0/linux-x64-48_binding.node
       
       > node-sass@4.5.0 postinstall /tmp/build_473136e9feee81831d3b2c2a9f63617d/node_modules/node-sass
       > node scripts/build.js
       
       Binary found at /tmp/build_473136e9feee81831d3b2c2a9f63617d/node_modules/node-sass/vendor/linux-x64-48/binding.node
       Testing binary
       Binary is fine
       
       > commandiv-next@1.0.0 postinstall /tmp/build_473136e9feee81831d3b2c2a9f63617d
       > heroku-nextjs-build
       
       
       > commandiv-next@1.0.0 build /app/nextjs
       > next build
       
       > Using external babel configuration
       > location: "/app/nextjs/.babelrc"
       > Using "webpack" config function defined in next.config.js.
       { Error: ./~/next/dist/client/index.js
       Module not found: Error: Can't resolve 'react' in '/app/nextjs/node_modules/next/dist/client'
       resolve 'react' in '/app/nextjs/node_modules/next/dist/client'
       Parsed request is a module
       using description file: /app/nextjs/node_modules/next/package.json (relative path: ./dist/client)
       Field 'browser' doesn't contain a valid alias configuration
       after using description file: /app/nextjs/node_modules/next/package.json (relative path: ./dist/client)
       resolve as module
       /app/node_modules doesn't exist or is not a directory
       /node_modules doesn't exist or is not a directory
       /app/nextjs/node_modules/next/dist/client/node_modules doesn't exist or is not a directory
       /app/nextjs/node_modules/next/dist/node_modules doesn't exist or is not a directory
       /app/nextjs/node_modules/node_modules doesn't exist or is not a directory
       looking for modules in /app/nextjs/node_modules/next/node_modules
       using description file: /app/nextjs/node_modules/next/package.json (relative path: ./node_modules)
       Field 'browser' doesn't contain a valid alias configuration
       after using description file: /app/nextjs/node_modules/next/package.json (relative path: ./node_modules)
       using description file: /app/nextjs/node_modules/next/package.json (relative path: ./node_modules/react)
       as directory
       /app/nextjs/node_modules/next/node_modules/react doesn't exist
       no extension
       Field 'browser' doesn't contain a valid alias configuration
       /app/nextjs/node_modules/next/node_modules/react doesn't exist
       .js
       Field 'browser' doesn't contain a valid alias configuration
       /app/nextjs/node_modules/next/node_modules/react.js doesn't exist
       .json
       Field 'browser' doesn't contain a valid alias configuration
       /app/nextjs/node_modules/next/node_modules/react.json doesn't exist
       looking for modules in /app/nextjs/node_modules/next/node_modules
       using description file: /app/nextjs/node_modules/next/package.json (relative path: ./node_modules)
       Field 'browser' doesn't contain a valid alias configuration
       after using description file: /app/nextjs/node_modules/next/package.json (relative path: ./node_modules)
       using description file: /app/nextjs/node_modules/next/package.json (relative path: ./node_modules/react)
       as directory
       /app/nextjs/node_modules/next/node_modules/react doesn't exist
       no extension
       Field 'browser' doesn't contain a valid alias configuration
       /app/nextjs/node_modules/next/node_modules/react doesn't exist
       .js
       Field 'browser' doesn't contain a valid alias configuration
       /app/nextjs/node_modules/next/node_modules/react.js doesn't exist
       .json
       Field 'browser' doesn't contain a valid alias configuration
       /app/nextjs/node_modules/next/node_modules/react.json doesn't exist
       looking for modules in /app/nextjs/node_modules
       using description file: /app/nextjs/package.json (relative path: ./node_modules)
       Field 'browser' doesn't contain a valid alias configuration
       after using description file: /app/nextjs/package.json (relative path: ./node_modules)
       using description file: /app/nextjs/package.json (relative path: ./node_modules/react)
       as directory
       /app/nextjs/node_modules/react doesn't exist

So I added react and react-dom as a dependency and it works, but a little confused as to how this never was a problem before. Closing...