From b433fc738e03fb4b0159510f24de60a2dce19af7 Mon Sep 17 00:00:00 2001 From: Uzo Agu Date: Mon, 12 Dec 2016 19:00:33 -0500 Subject: [PATCH 1/2] Adds note on how to resolve file or directory not found errors for heroku deployments --- packages/react-scripts/template/README.md | 24 ++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 4445e9b903a..687b80edc32 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1171,7 +1171,29 @@ GitHub Pages doesn't support routers that use the HTML5 `pushState` history API ### Heroku Use the [Heroku Buildpack for Create React App](https://github.com/mars/create-react-app-buildpack).
-You can find instructions in [Deploying React with Zero Configuration](https://blog.heroku.com/deploying-react-with-zero-configuration). +You can find instructions in [Deploying React with Zero Configuration](https://blog.heroku.com/deploying-react-with-zero-configuration). + +- **_resolving Module Not Found Errors when using [Heroku Buildpack for Create React App](https://github.com/mars/create-react-app-buildpack)_**.
+ - If `npm run build` works locally but fails while attempting to +deploy via heroku; specifically if you get an error similar to this: + + ``` + remote: Failed to create a production build. Reason: + remote: Module not found: Error: Cannot resolve 'file' or 'directory' + in /tmp/build_somenumber/src + ``` + You need to ensure that the lettercase of the name of 'file' or + 'directory' in question matches what you have commited to github.
+ + For example: heroku is searching for 'Filename' but you have + 'filename'.
+ + Reason for this is that Linux (the OS used in the Heroku + runtime) is case sensitive. So 'Filename' and 'filename' + are two distinct files and thus, even though it seems to work + locally, the difference in lettercase will break require/import + statements on heroku remotes. + ### Modulus From d029169b9911a23e98bbe0fe29c9b04fbefdfc79 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Tue, 13 Dec 2016 00:42:21 +0000 Subject: [PATCH 2/2] Style tweaks --- packages/react-scripts/template/README.md | 32 +++++++++++------------ 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 687b80edc32..fe4e7b31b12 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -64,6 +64,7 @@ You can find the most recent version of this guide [here](https://github.com/fac - [Troubleshooting](#troubleshooting) - [`npm test` hangs on macOS Sierra](#npm-test-hangs-on-macos-sierra) - [`npm run build` silently fails](#npm-run-build-silently-fails) + - [`npm run build` fails on Heroku](#npm-run-build-fails-on-heroku) - [Something Missing?](#something-missing) ## Updating to New Releases @@ -1173,27 +1174,19 @@ GitHub Pages doesn't support routers that use the HTML5 `pushState` history API Use the [Heroku Buildpack for Create React App](https://github.com/mars/create-react-app-buildpack).
You can find instructions in [Deploying React with Zero Configuration](https://blog.heroku.com/deploying-react-with-zero-configuration). -- **_resolving Module Not Found Errors when using [Heroku Buildpack for Create React App](https://github.com/mars/create-react-app-buildpack)_**.
- - If `npm run build` works locally but fails while attempting to -deploy via heroku; specifically if you get an error similar to this: +#### Resolving "Module not found: Error: Cannot resolve 'file' or 'directory'" - ``` - remote: Failed to create a production build. Reason: - remote: Module not found: Error: Cannot resolve 'file' or 'directory' - in /tmp/build_somenumber/src - ``` - You need to ensure that the lettercase of the name of 'file' or - 'directory' in question matches what you have commited to github.
+Sometimes `npm run build` works locally but fails during deploy via Heroku with an error like this: - For example: heroku is searching for 'Filename' but you have - 'filename'.
+``` +remote: Failed to create a production build. Reason: +remote: Module not found: Error: Cannot resolve 'file' or 'directory' +MyDirectory in /tmp/build_1234/src +``` - Reason for this is that Linux (the OS used in the Heroku - runtime) is case sensitive. So 'Filename' and 'filename' - are two distinct files and thus, even though it seems to work - locally, the difference in lettercase will break require/import - statements on heroku remotes. +This means you need to ensure that the lettercase of the file or directory you `import` matches the one you see on your filesystem or on GitHub. +This is important because Linux (the operating system used by Heroku) is case sensitive. So `MyDirectory` and `mydirectory` are two distinct directories and thus, even though the project builds locally, the difference in case breaks the `import` statements on Heroku remotes. ### Modulus @@ -1287,6 +1280,11 @@ There are also reports that *uninstalling* Watchman fixes the issue. So if nothi It is reported that `npm run build` can fail on machines with no swap space, which is common in cloud environments. If [the symptoms are matching](https://github.com/facebookincubator/create-react-app/issues/1133#issuecomment-264612171), consider adding some swap space to the machine you’re building on, or build the project locally. +### `npm run build` fails on Heroku + +This may be a problem with case sensitive filenames. +Please refer to [this section](#resolving-module-not-found-error-cannot-resolve-file-or-directory). + ## Something Missing? If you have ideas for more “How To” recipes that should be on this page, [let us know](https://github.com/facebookincubator/create-react-app/issues) or [contribute some!](https://github.com/facebookincubator/create-react-app/edit/master/packages/react-scripts/template/README.md)