create-react-app: Module not found: Error: Cannot resolve 'file' or 'directory'

Description

Deployment to Heroku fails when searching for a custom directory.

Error

remote: Failed to create a production build. Reason: remote: Module not found: Error: Cannot resolve ‘file’ or ‘directory’ …/components/layouts/main/main in /tmp/build_2382a25e2b852366900fece204e3330d/src remote: remote: npm ERR! Linux 3.13.0-95-generic remote: npm ERR! argv “/tmp/build_2382a25e2b852366900fece204e3330d/.heroku/node/bin/node” “/tmp/build_2382a25e2b852366900fece204e3330d/.heroku/node/bin/npm” “run” “build” remote: npm ERR! node v5.11.1 remote: npm ERR! npm v3.8.6 remote: npm ERR! code ELIFECYCLE remote: npm ERR! directumApp@0.1.0 build: react-scripts build remote: npm ERR! Exit status 1 remote: npm ERR! remote: npm ERR! Failed at the directumApp@0.1.0 build script ‘react-scripts build’. remote: npm ERR! Make sure you have the latest version of node.js and npm installed. remote: npm ERR! If you do, this is most likely a problem with the directumApp package, remote: npm ERR! not with npm itself. remote: npm ERR! Tell the author that this fails on your system: remote: npm ERR! react-scripts build remote: npm ERR! You can get information on how to open an issue for this project with: remote: npm ERR! npm bugs directumApp remote: npm ERR! Or if that isn’t available, you can get their info via: remote: npm ERR! npm owner ls directumApp remote: npm ERR! There is likely additional logging output above. remote: remote: npm ERR! Please include the following file with any support request: remote: npm ERR! /tmp/build_2382a25e2b852366900fece204e3330d/npm-debug.log remote: ! Push rejected, failed to compile React.js (create-react-app) multi app. remote: remote: ! Push failed remote: Verifying deploy… remote: remote: ! Push rejected to directumapp. remote: To https://git.heroku.com/directumapp.git ! [remote rejected] develop -> master (pre-receive hook declined) error: failed to push some refs to ‘https://git.heroku.com/directumapp.git

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 42 (26 by maintainers)

Most upvoted comments

It likely doesn’t install devDependencies which is where react-scripts is.

I’m using the Heroku guides specified on the project read me that was generates by Create React App. Let me see if I can share the project with you.

sh: react-scripts: command not found

means you didn’t run npm install, or it failed, so it was not installed.

Can you please run:

npm install -g npm@latest
rm -rf node_modules
npm install

and then run

npm run build