Skip to content

Commit 7a8edf0

Browse files
msuzoagugaearon
authored andcommitted
Heroku Deployment: Adds a note on how to resolve "File/Module Not Found Errors" (#1260)
* Adds note on how to resolve file or directory not found errors for heroku deployments * Style tweaks
1 parent ab3913c commit 7a8edf0

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

packages/react-scripts/template/README.md

+21-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ You can find the most recent version of this guide [here](https://github.com/fac
6464
- [Troubleshooting](#troubleshooting)
6565
- [`npm test` hangs on macOS Sierra](#npm-test-hangs-on-macos-sierra)
6666
- [`npm run build` silently fails](#npm-run-build-silently-fails)
67+
- [`npm run build` fails on Heroku](#npm-run-build-fails-on-heroku)
6768
- [Something Missing?](#something-missing)
6869

6970
## Updating to New Releases
@@ -1171,7 +1172,21 @@ GitHub Pages doesn't support routers that use the HTML5 `pushState` history API
11711172
### Heroku
11721173
11731174
Use the [Heroku Buildpack for Create React App](https://github.com/mars/create-react-app-buildpack).<br>
1174-
You can find instructions in [Deploying React with Zero Configuration](https://blog.heroku.com/deploying-react-with-zero-configuration).
1175+
You can find instructions in [Deploying React with Zero Configuration](https://blog.heroku.com/deploying-react-with-zero-configuration).
1176+
1177+
#### Resolving "Module not found: Error: Cannot resolve 'file' or 'directory'"
1178+
1179+
Sometimes `npm run build` works locally but fails during deploy via Heroku with an error like this:
1180+
1181+
```
1182+
remote: Failed to create a production build. Reason:
1183+
remote: Module not found: Error: Cannot resolve 'file' or 'directory'
1184+
MyDirectory in /tmp/build_1234/src
1185+
```
1186+
1187+
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.
1188+
1189+
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.
11751190
11761191
### Modulus
11771192
@@ -1265,6 +1280,11 @@ There are also reports that *uninstalling* Watchman fixes the issue. So if nothi
12651280
12661281
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.
12671282
1283+
### `npm run build` fails on Heroku
1284+
1285+
This may be a problem with case sensitive filenames.
1286+
Please refer to [this section](#resolving-module-not-found-error-cannot-resolve-file-or-directory).
1287+
12681288
## Something Missing?
12691289
12701290
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)

0 commit comments

Comments
 (0)