This is similar to other questions, but I'll explain what's different.
Like the many others, I have an app that works fine on my own server, but when I push to Heroku, I get the following error:
remote: > react-scripts build
remote:
remote: module.js:549
remote: throw err;
remote: ^
remote:
remote: Error: Cannot find module './error'
remote: at Function.Module._resolveFilename (module.js:547:15)
remote: at Function.Module._load (module.js:474:25)
remote: at Module.require (module.js:596:17)
remote: at require (internal/module.js:11:18)
remote: at Object.<anonymous> (/tmp/build_96886a1c0acbba91a1be57ec9c1487e8/client/node_modules/browserslist/index.js:7:25)
remote: at Module._compile (module.js:652:30)
remote: at Object.Module._extensions..js (module.js:663:10)
remote: at Module.load (module.js:565:32)
remote: at tryModuleLoad (module.js:505:12)
remote: at Function.Module._load (module.js:497:3)
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! client@0.1.0 build: `react-scripts build`
The difference, is I have no require('./error')
or file or folder or dependency installed called error.
I have tried the following:
1.
npm install -g
2.
Delete node_modules
npm cache clean --force
npm install
3. Added to my package.json:
"engines": {
"node": "8.11.3"
}
4. Three times from scratch I cloned my working app, created a new Heroku instance, and tried to deploy.
5. Tried this:
heroku config:set NODE_MODULES_CACHE=false
These solutions and others that didn't work came from these posts:
How do I resolve "Cannot find module" error using Node.js?
Heroku Deploy Error: Cannot get Node App running after Deploy : Cannot find module '/app/web.js'
Heroku Deploy Error: Cannot find module './errors/cast'
Error: Cannot find module './shared'
https://github.com/nodejs/help/issues/1271
https://help.heroku.com/TO64O3OG/cannot-find-module-in-node-js-at-runtime