App works locally but getteting error on heroku - node.js

I'm working on an amazon clone app from a turorial. It works locally and it will deploy to heroku with no errors but I get a Module Not Found for the productsController.
The file structure is
├── backend
| ├── config
│ ├── controllers
│ │ ├── productController.js
│ ├── models
│ ├── routes
│ │ ├── productRoutes.js
│ ├── server.js
Here is the heroku error log:
2023-01-06T01:09:09.693860+00:00 app[web.1]: ^
2023-01-06T01:09:09.693860+00:00 app[web.1]:
2023-01-06T01:09:09.693861+00:00 app[web.1]: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/backend/controllers/productController.js' imported from /app/backend/routes/productRoutes.js
2023-01-06T01:09:09.693861+00:00 app[web.1]: at new NodeError (node:internal/errors:393:5)
2023-01-06T01:09:09.693862+00:00 app[web.1]: at finalizeResolution (node:internal/modules/esm/resolve:323:11)
2023-01-06T01:09:09.693862+00:00 app[web.1]: at moduleResolve (node:internal/modules/esm/resolve:916:10)
2023-01-06T01:09:09.693862+00:00 app[web.1]: at defaultResolve (node:internal/modules/esm/resolve:1124:11)
2023-01-06T01:09:09.693863+00:00 app[web.1]: at nextResolve (node:internal/modules/esm/loader:163:28)
2023-01-06T01:09:09.693863+00:00 app[web.1]: at ESMLoader.resolve (node:internal/modules/esm/loader:841:30)
2023-01-06T01:09:09.693863+00:00 app[web.1]: at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
2023-01-06T01:09:09.693864+00:00 app[web.1]: at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
2023-01-06T01:09:09.693875+00:00 app[web.1]: at link (node:internal/modules/esm/module_job:75:36) {
2023-01-06T01:09:09.693875+00:00 app[web.1]: code: 'ERR_MODULE_NOT_FOUND'
2023-01-06T01:09:09.693875+00:00 app[web.1]: }
2023-01-06T01:09:09.693880+00:00 app[web.1]:
2023-01-06T01:09:09.693880+00:00 app[web.1]: Node.js v18.12.1
2023-01-06T01:09:09.881953+00:00 heroku[web.1]: Process exited with status 1
2023-01-06T01:09:09.926097+00:00 heroku[web.1]: State changed from starting to crashed
2023-01-06T01:09:09.936162+00:00 heroku[web.1]: State changed from crashed to starting
2023-01-06T01:09:18.922072+00:00 heroku[web.1]: Starting process with command `npm start`
2023-01-06T01:09:20.986680+00:00 app[web.1]:
2023-01-06T01:09:20.986716+00:00 app[web.1]: > amazona-2#1.0.0 start
2023-01-06T01:09:20.986716+00:00 app[web.1]: > node backend/server.js
2023-01-06T01:09:20.986717+00:00 app[web.1]:
2023-01-06T01:09:21.087388+00:00 app[web.1]: node:internal/errors:484
2023-01-06T01:09:21.087389+00:00 app[web.1]: ErrorCaptureStackTrace(err);
2023-01-06T01:09:21.087390+00:00 app[web.1]: ^
2023-01-06T01:09:21.087390+00:00 app[web.1]:
2023-01-06T01:09:21.087391+00:00 app[web.1]: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/backend/controllers/productController.js' imported from /app/backend/routes/productRoutes.js
2023-01-06T01:09:21.087391+00:00 app[web.1]: at new NodeError (node:internal/errors:393:5)
2023-01-06T01:09:21.087392+00:00 app[web.1]: at finalizeResolution (node:internal/modules/esm/resolve:323:11)
2023-01-06T01:09:21.087392+00:00 app[web.1]: at moduleResolve (node:internal/modules/esm/resolve:916:10)
2023-01-06T01:09:21.087392+00:00 app[web.1]: at defaultResolve (node:internal/modules/esm/resolve:1124:11)
2023-01-06T01:09:21.087393+00:00 app[web.1]: at nextResolve (node:internal/modules/esm/loader:163:28)
2023-01-06T01:09:21.087393+00:00 app[web.1]: at ESMLoader.resolve (node:internal/modules/esm/loader:841:30)
2023-01-06T01:09:21.087393+00:00 app[web.1]: at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
2023-01-06T01:09:21.087394+00:00 app[web.1]: at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
2023-01-06T01:09:21.087395+00:00 app[web.1]: at link (node:internal/modules/esm/module_job:75:36) {
2023-01-06T01:09:21.087396+00:00 app[web.1]: code: 'ERR_MODULE_NOT_FOUND'
2023-01-06T01:09:21.087396+00:00 app[web.1]: }
2023-01-06T01:09:21.087426+00:00 app[web.1]:
2023-01-06T01:09:21.087427+00:00 app[web.1]: Node.js v18.12.1
2023-01-06T01:09:21.248317+00:00 heroku[web.1]: Process exited with status 1
2023-01-06T01:09:21.315476+00:00 heroku[web.1]: State changed from starting to crashed
2023-01-06T01:09:23.209214+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mern-amazona2-judo2000.herokuapp.com request_id=dd865b46-6a9f-478d-87ea-bfef1a20773d fwd="136.144.43.249" dyno= connect= service= status=503 bytes= protocol=https
2023-01-06T01:09:23.521669+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=mern-amazona2-judo2000.herokuapp.com request_id=2c983834-c3e2-4a60-b39a-f55ecf4fa2fd fwd="172.98.33.99" dyno= connect= service=
status=503 bytes= protocol=https
2023-01-06T01:11:30.804412+00:00 heroku[web.1]: State changed from crashed to starting
2023-01-06T01:11:39.211361+00:00 heroku[web.1]: Starting process with command `npm start`
2023-01-06T01:11:41.347517+00:00 app[web.1]:
2023-01-06T01:11:41.347544+00:00 app[web.1]: > amazona-2#1.0.0 start
2023-01-06T01:11:41.347544+00:00 app[web.1]: > node backend/server.js
2023-01-06T01:11:41.347545+00:00 app[web.1]:
2023-01-06T01:11:41.460279+00:00 app[web.1]: node:internal/errors:484
2023-01-06T01:11:41.460280+00:00 app[web.1]: ErrorCaptureStackTrace(err);
2023-01-06T01:11:41.460281+00:00 app[web.1]: ^
2023-01-06T01:11:41.460281+00:00 app[web.1]:
2023-01-06T01:11:41.460281+00:00 app[web.1]: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/backend/controllers/productController.js' imported from /app/backend/routes/productRoutes.js
2023-01-06T01:11:41.460282+00:00 app[web.1]: at new NodeError (node:internal/errors:393:5)
2023-01-06T01:11:41.460282+00:00 app[web.1]: at finalizeResolution (node:internal/modules/esm/resolve:323:11)
2023-01-06T01:11:41.460283+00:00 app[web.1]: at moduleResolve (node:internal/modules/esm/resolve:916:10)
2023-01-06T01:11:41.460283+00:00 app[web.1]: at defaultResolve (node:internal/modules/esm/resolve:1124:11)
2023-01-06T01:11:41.460283+00:00 app[web.1]: at nextResolve (node:internal/modules/esm/loader:163:28)
2023-01-06T01:11:41.460285+00:00 app[web.1]: at ESMLoader.resolve (node:internal/modules/esm/loader:841:30)
2023-01-06T01:11:41.460285+00:00 app[web.1]: at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
2023-01-06T01:11:41.460285+00:00 app[web.1]: at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
2023-01-06T01:11:41.460285+00:00 app[web.1]: at link (node:internal/modules/esm/module_job:75:36) {
2023-01-06T01:11:41.460286+00:00 app[web.1]: code: 'ERR_MODULE_NOT_FOUND'
2023-01-06T01:11:41.460286+00:00 app[web.1]: }
2023-01-06T01:11:41.460297+00:00 app[web.1]:
2023-01-06T01:11:41.460298+00:00 app[web.1]: Node.js v18.12.1
2023-01-06T01:11:41.609123+00:00 heroku[web.1]: Process exited with status 1
2023-01-06T01:11:41.742528+00:00 heroku[web.1]: State changed from starting to crashed
2023-01-06T01:11:42.461013+00:00 heroku[web.1]: State changed from crashed to starting
2023-01-06T01:11:52.618745+00:00 heroku[web.1]: Starting process with command `npm start`
2023-01-06T01:11:54.470268+00:00 app[web.1]:
2023-01-06T01:11:54.470310+00:00 app[web.1]: > amazona-2#1.0.0 start
2023-01-06T01:11:54.470311+00:00 app[web.1]: > node backend/server.js
2023-01-06T01:11:54.470311+00:00 app[web.1]:
2023-01-06T01:11:54.565973+00:00 app[web.1]: node:internal/errors:484
2023-01-06T01:11:54.565975+00:00 app[web.1]: ErrorCaptureStackTrace(err);
2023-01-06T01:11:54.565975+00:00 app[web.1]: ^
2023-01-06T01:11:54.565976+00:00 app[web.1]:
2023-01-06T01:11:54.565977+00:00 app[web.1]: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/backend/controllers/productController.js' imported from /app/backend/routes/productRoutes.js
2023-01-06T01:11:54.565986+00:00 app[web.1]: at new NodeError (node:internal/errors:393:5)
2023-01-06T01:11:54.565986+00:00 app[web.1]: at finalizeResolution (node:internal/modules/esm/resolve:323:11)
2023-01-06T01:11:54.565986+00:00 app[web.1]: at moduleResolve (node:internal/modules/esm/resolve:916:10)
2023-01-06T01:11:54.565987+00:00 app[web.1]: at defaultResolve (node:internal/modules/esm/resolve:1124:11)
2023-01-06T01:11:54.565987+00:00 app[web.1]: at nextResolve (node:internal/modules/esm/loader:163:28)
2023-01-06T01:11:54.565987+00:00 app[web.1]: at ESMLoader.resolve (node:internal/modules/esm/loader:841:30)
2023-01-06T01:11:54.565987+00:00 app[web.1]: at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
2023-01-06T01:11:54.565993+00:00 app[web.1]: Node.js v18.12.12023-01-06T01:11:54.697714+00:00 heroku[web.1]: Process exited with status 1
2023-01-06T01:11:54.792281+00:00 heroku[web.1]: State changed from starting to crashed
2023-01-06T01:11:55.983110+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mern-amazona2-judo2000.herokuapp.com request_id=e373b75d-6a72-432d-9709-29e6c62063bd fwd="173.239.224.8" dyno= connect= service= status=503 bytes= protocol=https
2023-01-06T01:11:56.274300+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=mern-amazona2-judo2000.herokuapp.com request_id=368733e0-a442-422d-97a1-1c3e0bc7681f fwd="173.239.224.10" dyno= connect= service= status=503 bytes= protocol=https
2023-01-06T01:11:30.571160+00:00 app[api]: Release v21 created by user judo2000#comcast.net
2023-01-06T01:11:30.571160+00:00 app[api]: Remove MONGO_URI config vars by user judo2000#comcast.net
2023-01-06T01:11:42.194061+00:00 app[api]: Set MONGODB_URI config vars by user judo2000#comcast.net
2023-01-06T01:11:42.194061+00:00 app[api]: Release v22 created by user judo2000#comcast.net
Here is the server.js
import express from 'express';
import path from 'path';
import dotenv from 'dotenv';
import connectDB from './config/connection.js';
import seedRoutes from './routes/seedRoutes.js';
import productRoutes from './routes/productRoutes.js';
import userRoutes from './routes/userRoutes.js';
import orderRoutes from './routes/orderRoutes.js';
dotenv.config();
connectDB();
const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.get('/api/keys/paypal', (req, res) => {
res.send(process.env.PAYPAL_CLIENT_ID || 'sb');
});
app.use('/api/seed', seedRoutes);
app.use('/api/products', productRoutes);
app.use('/api/users', userRoutes);
app.use('/api/orders', orderRoutes);
const __dirname = path.resolve();
app.use(express.static(path.join(__dirname, '/frontend/build')));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, '/frontend/build/index.html'));
});
app.use((err, req, res, next) => {
res.status(500).send({ message: err.message });
});
const port = process.env.PORT || 5000;
app.listen(port, () => {
console.log(`Server listening at http://localhost:${port}`);
});
Here is the productRoutes.js
import express, { Router } from 'express';
const router = express.Router();
import {
getProducts,
getProductBySlug,
getProductById,
} from '../controllers/productController.js';
router.route('/').get(getProducts);
router.route('/slug/:slug').get(getProductBySlug);
router.route('/:id').get(getProductById);
export default router;
And here is the productController
import Product from '../models/ProductModel.js';
const getProducts = async (req, res) => {
const products = await Product.find({});
res.send(products);
};
const getProductBySlug = async (req, res) => {
const product = await Product.findOne({ slug: req.params.slug });
if (product) {
res.send(product);
} else {
res.status(404).send({ message: 'Product Not Found' });
}
};
const getProductById = async (req, res) => {
const product = await Product.findById(req.params.id);
if (product) {
res.send(product);
} else {
res.status(404).send({ message: 'Product not found.' });
}
};
export { getProducts, getProductBySlug, getProductById };

You have a path mis-match. Change controllers to controller or vise-versa (whichever is true).
The error is:
Cannot find module '/app/backend/controllers/productController.js'
and your path is:
/app/backend/controller/productController.js

Related

Node.js heroku deploy failure

My app works locally, but when trying to deploy I get code=H10. I have tried looking up code=H10 failures, but they all see to lead to changes with process.env.PORT changes, which I have already done in various ways.
This is my first time deploying to heroku, so sorry if I am missing some important information.
Any advice will be much appreciated.
My logs:
2021-05-16T23:27:11.291289+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
2021-05-16T23:27:11.291289+00:00 app[web.1]: at node:internal/main/run_main_module:17:47 {
2021-05-16T23:27:11.291289+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-05-16T23:27:11.291290+00:00 app[web.1]: requireStack: []
2021-05-16T23:27:11.291290+00:00 app[web.1]: }
2021-05-16T23:27:11.341722+00:00 heroku[web.1]: Process exited with status 1
2021-05-16T23:27:11.432934+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-16T23:27:55.798013+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=thenewslab.herokuapp.com request_id=3428bce1-739d-47ed-9205-9859475e0e22 fwd="46.69.82.216" dyno= connect= service= status=503 bytes= protocol=https
2021-05-16T23:33:49.000000+00:00 app[api]: Build started by user joshuamacleod#live.com
2021-05-16T23:36:06.038437+00:00 app[api]: Release v17 created by user joshuamacleod#live.com
2021-05-16T23:36:06.038437+00:00 app[api]: Deploy 31855de1 by user joshuamacleod#live.com
2021-05-16T23:36:06.264449+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-16T23:36:07.000000+00:00 app[api]: Build succeeded
2021-05-16T23:36:19.886178+00:00 heroku[web.1]: Starting process with command `node build/server.js`
2021-05-16T23:36:22.175404+00:00 app[web.1]: node:internal/modules/cjs/loader:944
2021-05-16T23:36:22.175424+00:00 app[web.1]: throw err;
2021-05-16T23:36:22.175425+00:00 app[web.1]: ^
2021-05-16T23:36:22.175425+00:00 app[web.1]:
2021-05-16T23:36:22.175426+00:00 app[web.1]: Error: Cannot find module '/app/build/server.js'
2021-05-16T23:36:22.175426+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15)
2021-05-16T23:36:22.175427+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:774:27)
2021-05-16T23:36:22.175427+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
2021-05-16T23:36:22.175428+00:00 app[web.1]: at node:internal/main/run_main_module:17:47 {
2021-05-16T23:36:22.175428+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-05-16T23:36:22.175429+00:00 app[web.1]: requireStack: []
2021-05-16T23:36:22.175429+00:00 app[web.1]: }
2021-05-16T23:36:22.240102+00:00 heroku[web.1]: Process exited with status 1
2021-05-16T23:36:22.322859+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-16T23:36:50.313742+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=thenewslab.herokuapp.com request_id=0e8e0047-c98d-4126-9008-c50c7d927320 fwd="46.69.82.216" dyno= connect= service= status=503 bytes= protocol=https
2021-05-16T23:43:04.802415+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-16T23:43:19.981689+00:00 heroku[web.1]: Starting process with command `node build/server.js`
2021-05-16T23:43:22.004092+00:00 app[web.1]: node:internal/modules/cjs/loader:944
2021-05-16T23:43:22.004127+00:00 app[web.1]: throw err;
2021-05-16T23:43:22.004127+00:00 app[web.1]: ^
2021-05-16T23:43:22.004128+00:00 app[web.1]:
2021-05-16T23:43:22.004128+00:00 app[web.1]: Error: Cannot find module '/app/build/server.js'
2021-05-16T23:43:22.004129+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15)
2021-05-16T23:43:22.004129+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:774:27)
2021-05-16T23:43:22.004130+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
2021-05-16T23:43:22.004130+00:00 app[web.1]: at node:internal/main/run_main_module:17:47 {
2021-05-16T23:43:22.004130+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-05-16T23:43:22.004131+00:00 app[web.1]: requireStack: []
2021-05-16T23:43:22.004131+00:00 app[web.1]: }
2021-05-16T23:43:22.064674+00:00 heroku[web.1]: Process exited with status 1
2021-05-16T23:43:22.121461+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-16T23:56:01.000000+00:00 app[api]: Build started by user joshuamacleod#live.com
2021-05-16T23:58:17.578622+00:00 app[api]: Release v18 created by user joshuamacleod#live.com
2021-05-16T23:58:17.578622+00:00 app[api]: Deploy 09023d82 by user joshuamacleod#live.com
2021-05-16T23:58:17.959761+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-16T23:58:19.000000+00:00 app[api]: Build succeeded
2021-05-16T23:58:35.537730+00:00 heroku[web.1]: Starting process with command `node server.js`
2021-05-16T23:58:38.809616+00:00 app[web.1]: node:internal/modules/cjs/loader:944
2021-05-16T23:58:38.809639+00:00 app[web.1]: throw err;
2021-05-16T23:58:38.809640+00:00 app[web.1]: ^
2021-05-16T23:58:38.809640+00:00 app[web.1]:
2021-05-16T23:58:38.809640+00:00 app[web.1]: Error: Cannot find module '/Users/joshua/makers/thenewslab/news-server/db'
2021-05-16T23:58:38.809641+00:00 app[web.1]: Require stack:
2021-05-16T23:58:38.809641+00:00 app[web.1]: - /app/routes/api/users.js
2021-05-16T23:58:38.809641+00:00 app[web.1]: - /app/server.js
2021-05-16T23:58:38.809642+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15)
2021-05-16T23:58:38.809643+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:774:27)
2021-05-16T23:58:38.809643+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1013:19)
2021-05-16T23:58:38.809643+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:93:18)
2021-05-16T23:58:38.809644+00:00 app[web.1]: at Object.<anonymous> (/app/routes/api/users.js:5:12)
2021-05-16T23:58:38.809644+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1109:14)
2021-05-16T23:58:38.809644+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
2021-05-16T23:58:38.809645+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:989:32)
2021-05-16T23:58:38.809645+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:829:14)
2021-05-16T23:58:38.809645+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1013:19) {
2021-05-16T23:58:38.809646+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-05-16T23:58:38.809646+00:00 app[web.1]: requireStack: [ '/app/routes/api/users.js', '/app/server.js' ]
2021-05-16T23:58:38.809648+00:00 app[web.1]: }
2021-05-16T23:58:38.902832+00:00 heroku[web.1]: Process exited with status 1
2021-05-16T23:58:38.974809+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-16T23:58:38.986788+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-16T23:58:50.650040+00:00 heroku[web.1]: Starting process with command `node server.js`
2021-05-16T23:58:52.992272+00:00 app[web.1]: node:internal/modules/cjs/loader:944
2021-05-16T23:58:52.992286+00:00 app[web.1]: throw err;
2021-05-16T23:58:52.992286+00:00 app[web.1]: ^
2021-05-16T23:58:52.992286+00:00 app[web.1]:
2021-05-16T23:58:52.992287+00:00 app[web.1]: Error: Cannot find module '/Users/joshua/makers/thenewslab/news-server/db'
2021-05-16T23:58:52.992287+00:00 app[web.1]: Require stack:
2021-05-16T23:58:52.992287+00:00 app[web.1]: - /app/routes/api/users.js
2021-05-16T23:58:52.992288+00:00 app[web.1]: - /app/server.js
2021-05-16T23:58:52.992288+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15)
2021-05-16T23:58:52.992288+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:774:27)
2021-05-16T23:58:52.992289+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1013:19)
2021-05-16T23:58:52.992289+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:93:18)
2021-05-16T23:58:52.992289+00:00 app[web.1]: at Object.<anonymous> (/app/routes/api/users.js:5:12)
2021-05-16T23:58:52.992290+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1109:14)
2021-05-16T23:58:52.992290+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
2021-05-16T23:58:52.992290+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:989:32)
2021-05-16T23:58:52.992290+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:829:14)
2021-05-16T23:58:52.992290+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1013:19) {
2021-05-16T23:58:52.992294+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-05-16T23:58:52.992294+00:00 app[web.1]: requireStack: [ '/app/routes/api/users.js', '/app/server.js' ]
2021-05-16T23:58:52.992294+00:00 app[web.1]: }
2021-05-16T23:58:53.061937+00:00 heroku[web.1]: Process exited with status 1
2021-05-16T23:58:53.120732+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-16T23:59:37.345240+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=thenewslab.herokuapp.com request_id=76cb051f-7ecc-451e-93cc-50f56beac59a fwd="46.69.82.216" dyno= connect= service= status=503 bytes= protocol=https
My server:
const express = require('express')
const bodyParser = require('body-parser')
const cors = require('cors')
const passport = require("passport");
const users = require("./routes/api/users");
const path = require("path");
const db = require('./db')
const articleRouter = require('./routes/article-router')
const app = express()
const server = process.env.PORT || 5000
app.use(bodyParser.urlencoded({
extended: true
}))
app.use(cors())
app.use(bodyParser.json())
app.use(passport.initialize());
app.use(express.static(path.join(__dirname, "client", "build")))
require("./config/passport")(passport);
db.on('error', console.error.bind(console, 'MongoDB connection error:'))
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.get("*", (req, res) => {
res.sendFile(path.join(__dirname, "client", "build", "index.html"));
});
app.use('/api', articleRouter)
app.use("/api/users", users);
app.listen(server, () => console.log(`Server running on port ${server}`))
My package.json:
{
"name": "news-server",
"version": "1.0.0",
"engines": {
"node": ">= 14.15.5",
"npm": "6.14.11"
},
"description": "",
"main": "server.js",
"scripts": {
"start": "node server.js",
"heroku-postbuild": "cd news-front && npm install --only=dev && npm install && npm run build"
}
My Procfile:
web: node server.js
A Procfile is not always necessary to deploy Node.js apps to Heroku, however, your package.json is very very important. The package.json file should include the modules to be installed. Which is missing.
The logs clearly say code: 'MODULE_NOT_FOUND', which means node_modules/ are missing.
You might have node_modules/ in your local system, but Heroku ignores it. It takes package.json and freshly starts to download it.
Heroku runs something like this. It Deletes node_modules/ then runs "npm install" then "node server.js"
For you, I would advice to always save your node_modules/ to package.json. This can be done while installing modules easily by adding --save
To debug this, do
"npm install --save express cors passport"
You can do this or do
"npm i --save express"
"npm i --save cors"
"npm i --save passport"
It is then showing me ./routes/api/users - I hope you have it.

NodeJS app deployed on heroku issue - not retrieving data from database

I'm having an issue with my full-stack application, (MySQL-Express-React-NodeJS). I have deployed it to Heroku everything is working except the pages that are connected to get or post to ClearDB MySQL database! Any advises or hints on something that I might have forgot to do? I'm also using the ClearDB add-on from Heroku if that helps.
server.js:
const express = require("express");
const bodyParser = require("body-parser");
const cors = require("cors");
const app = express();
const http = require("http");
const server = http.createServer(app);
const connection = require("./app/Models/database");
// require user the route
const user = require("./app/routes/user");
// require the doctor route
const doctor = require("./app/routes/doctor");
// require the question route
const questions = require("./app/routes/questions.js");
// require the schedule route
const schedule = require("./app/routes/schedule");
const appointement = require("./app/routes/appointment");
const socket = require("socket.io");
const io = socket(server);
app.use(cors());
// set the port
const port = process.env.PORT || 5000;
// parse requests of content-type - application/json
app.use(bodyParser.json());
// parse requests of content-type - application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true }));
// define the user router
app.use("/users", user);
app.use("/doctor", doctor);
app.use("/questions", questions);
app.use("/schedule", schedule);
app.use("/appointment", appointement);
app.use(function (error, req, res, next) {
if (error instanceof SyntaxError) {
//Handle SyntaxError here.
return res.status(500).send({ data: "Invalid data" });
} else {
next();
}
});
const peers = {};
io.on("connection", (socket) => {
//
if (!peers[socket.id]) {
peers[socket.id] = socket.id;
}
socket.emit("yourID", socket.id); // allows you to emit custom events on the server and client
io.sockets.emit("allUsers", peers); //will send to all the clients ......socket.broadcast.emit will send the message to all the other clients except the newly created connection
socket.on("disconnect", () => {
delete peers[socket.id]; //after the user leave the room
});
socket.on("callUser", (data) => {
io.to(data.userToCall).emit("hello", {
signal: data.signalData,
from: data.from,
}); //io.to('some room').emit('some event');
});
socket.on("acceptCall", (data) => {
io.to(data.to).emit("callAccepted", data.signal);
});
});
//test route
app.get("/test", function (req, res) {
res.send( "test");
});
app.listen(port, () => {
console.log(`Server is Running on port ${port}`);
});
Heroku logs:
2021-01-04T18:46:17.729977+00:00 heroku[web.1]: Restarting
2021-01-04T18:46:17.732430+00:00 heroku[web.1]: State changed from up to starting
2021-01-04T18:46:18.729190+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2021-01-04T18:46:18.801647+00:00 heroku[web.1]: Process exited with status 143
2021-01-04T18:46:53.555253+00:00 heroku[web.1]: Starting process with command `npm start`
2021-01-04T18:46:57.234794+00:00 app[web.1]:
2021-01-04T18:46:57.234819+00:00 app[web.1]: > server#1.0.0 start
2021-01-04T18:46:57.234819+00:00 app[web.1]: > node server.js
2021-01-04T18:46:57.234820+00:00 app[web.1]:
2021-01-04T18:46:58.471423+00:00 app[web.1]: /app/server.js:61
2021-01-04T18:46:58.471444+00:00 app[web.1]: console.log(`Server is Running in port:${port}`);
2021-01-04T18:46:58.471446+00:00 app[web.1]: ^
2021-01-04T18:46:58.471446+00:00 app[web.1]:
2021-01-04T18:46:58.471447+00:00 app[web.1]: ReferenceError: port is not defined
2021-01-04T18:46:58.471447+00:00 app[web.1]: at Server.<anonymous> (/app/server.js:61:44)
2021-01-04T18:46:58.471447+00:00 app[web.1]: at Object.onceWrapper (node:events:482:28)
2021-01-04T18:46:58.471448+00:00 app[web.1]: at Server.emit (node:events:388:22)
2021-01-04T18:46:58.471448+00:00 app[web.1]: at emitListeningNT (node:net:1329:10)
2021-01-04T18:46:58.471449+00:00 app[web.1]: at processTicksAndRejections (node:internal/process/task_queues:79:21)
2021-01-04T18:46:58.502509+00:00 app[web.1]: npm ERR! code 1
2021-01-04T18:46:58.503140+00:00 app[web.1]: npm ERR! path /app
2021-01-04T18:46:58.509321+00:00 app[web.1]: npm ERR! command failed
2021-01-04T18:46:58.509747+00:00 app[web.1]: npm ERR! command sh -c node server.js
2021-01-04T18:46:58.536286+00:00 app[web.1]:
2021-01-04T18:46:58.542292+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-01-04T18:46:58.542507+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-01-04T18_46_58_510Z-debug.log
2021-01-04T18:46:58.614100+00:00 heroku[web.1]: Process exited with status 1
2021-01-04T18:46:58.673495+00:00 heroku[web.1]: State changed from starting to crashed
2021-01-04T18:46:58.677305+00:00 heroku[web.1]: State changed from crashed to starting
2021-01-04T18:47:24.050526+00:00 heroku[web.1]: Starting process with command `npm start`
2021-01-04T18:47:27.323089+00:00 app[web.1]:
2021-01-04T18:47:27.323103+00:00 app[web.1]: > server#1.0.0 start
2021-01-04T18:47:27.323103+00:00 app[web.1]: > node server.js
2021-01-04T18:47:27.323104+00:00 app[web.1]:
2021-01-04T18:47:27.950882+00:00 app[web.1]: /app/server.js:61
2021-01-04T18:47:27.950900+00:00 app[web.1]: console.log(`Server is Running in port:${port}`);
2021-01-04T18:47:27.950901+00:00 app[web.1]: ^
2021-01-04T18:47:27.950903+00:00 app[web.1]:
2021-01-04T18:47:27.950903+00:00 app[web.1]: ReferenceError: port is not defined
2021-01-04T18:47:27.950903+00:00 app[web.1]: at Server.<anonymous> (/app/server.js:61:44)
2021-01-04T18:47:27.950904+00:00 app[web.1]: at Object.onceWrapper (node:events:482:28)
2021-01-04T18:47:27.950904+00:00 app[web.1]: at Server.emit (node:events:388:22)
2021-01-04T18:47:27.950904+00:00 app[web.1]: at emitListeningNT (node:net:1329:10)
2021-01-04T18:47:27.950905+00:00 app[web.1]: at processTicksAndRejections (node:internal/process/task_queues:79:21)
2021-01-04T18:47:27.970852+00:00 app[web.1]: npm ERR! code 1
2021-01-04T18:47:27.971425+00:00 app[web.1]: npm ERR! path /app
2021-01-04T18:47:27.976210+00:00 app[web.1]: npm ERR! command failed
2021-01-04T18:47:27.976596+00:00 app[web.1]: npm ERR! command sh -c node server.js
2021-01-04T18:47:27.987341+00:00 app[web.1]:
2021-01-04T18:47:27.987620+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-01-04T18:47:27.987792+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-01-04T18_47_27_977Z-debug.log
2021-01-04T18:47:28.067423+00:00 heroku[web.1]: Process exited with status 1
2021-01-04T18:47:28.111585+00:00 heroku[web.1]: State changed from starting to crashed
2021-01-04T18:48:09.000000+00:00 app[api]: Build started by user ishaqatfarah#gmail.com
2021-01-04T18:50:08.503349+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=speakout-2.herokuapp.com request_id=41eadebc-6547-4735-975c-47f07af41139 fwd="46.185.242.147" dyno= connect= service= status=503 bytes= protocol=https
2021-01-04T18:50:13.899678+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=speakout-2.herokuapp.com request_id=f9c641f9-30c1-4ef7-a184-0d286cecf4c0 fwd="46.185.242.147" dyno= connect= service= status=503 bytes= protocol=https
2021-01-04T18:50:37.722683+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=speakout-2.herokuapp.com request_id=a897151b-2c68-440d-bb39-877ad0e80b3c fwd="46.185.242.147" dyno= connect= service= status=503 bytes= protocol=https
2021-01-04T18:50:38.328012+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=speakout-2.herokuapp.com request_id=3b546e46-3812-4a18-8f78-f585c9f3e740 fwd="46.185.242.147" dyno= connect= service= status=503 bytes= protocol=https
2021-01-04T18:50:44.226260+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=speakout-2.herokuapp.com request_id=df1690f0-5e59-4105-aae7-857d2a2ef8ff fwd="46.185.242.147" dyno= connect= service= status=503 bytes= protocol=https
2021-01-04T18:50:44.682096+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=speakout-2.herokuapp.com request_id=d4bee131-4929-4f80-96dd-d829a6c53bde fwd="46.185.242.147" dyno= connect= service= status=503 bytes= protocol=https

Heroku Node.js Error "Error MongoNetworkError", "Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch"

I'm new in nodeJS,
I want upload my backend on Heroku to my Frontend but I got this Error
This code work in localhost,
I Added NODE_DATABASE in Heroku
"Error MongoNetworkError", "Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch"
my app.js
const dotenv = require("dotenv").load();
const express = require("express");
const session = require("express-session");
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
const passport = require("passport");
const morgan = require("morgan");
const cors = require("cors");
const LocalStrategy = require("passport-local").Strategy;
const routes = require("./routes");
const User = require("./models/User");
const MongoStore = require("connect-mongo")(session);
const PORT = process.env.PORT || 9000;
const app = express();
app.use(bodyParser.json());
app.use(morgan("combined"));
app.use(cors());
passport.use(new LocalStrategy(User.authenticate()));
passport.serializeUser(User.serializeUser());
passport.deserializeUser(User.deserializeUser());
app.use(
session({
secret: "Norbert",
resave: false,
saveUninitialized: true,
cookie: { maxAge: 86400000 },
store: new MongoStore({
mongooseConnection: mongoose.connection,
}),
})
);
app.use(express.urlencoded({ extended: true }));
app.use(passport.initialize());
app.use(passport.session());
mongoose.connect(process.env.NODE_DATABASE, { useNewUrlParser: true });
const conn = mongoose.connection;
conn.on("error", console.error.bind(console, "connection error:"));
conn.once("open", () => {
console.log("Connected to mlab database!");
app.listen(PORT, () => console.log(`App is listening on port ${PORT}!`));
app.use("/api", routes);
});
heroku logs
2020-08-20T10:05:53.139695+00:00 app[web.1]: [nodemon] starting `babel-node src/app.js`
2020-08-20T10:05:54.067319+00:00 app[web.1]: Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`
2020-08-20T10:05:55.810360+00:00 app[web.1]: connection error: MongoNetworkError: connection 5 to cluster0-shard-00-01.ho4na.mongodb.net:27017 closed
2020-08-20T10:05:55.810364+00:00 app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:276:9)
2020-08-20T10:05:55.810364+00:00 app[web.1]: at Object.onceWrapper (events.js:422:26)
2020-08-20T10:05:55.810365+00:00 app[web.1]: at TLSSocket.emit (events.js:327:22)
2020-08-20T10:05:55.810365+00:00 app[web.1]: at net.js:674:12
2020-08-20T10:05:55.810365+00:00 app[web.1]: at TCP.done (_tls_wrap.js:563:7) {
2020-08-20T10:05:55.810369+00:00 app[web.1]: name: 'MongoNetworkError',
2020-08-20T10:05:55.810369+00:00 app[web.1]: errorLabels: [ 'TransientTransactionError' ],
2020-08-20T10:05:55.810369+00:00 app[web.1]: [Symbol(mongoErrorContextSymbol)]: {}
2020-08-20T10:05:55.810370+00:00 app[web.1]: }
2020-08-20T10:05:55.828088+00:00 app[web.1]: [nodemon] clean exit - waiting for changes before restart
2020-08-20T10:06:50.472320+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-08-20T10:06:50.496970+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-08-20T10:06:50.575809+00:00 heroku[web.1]: Process exited with status 137
2020-08-20T10:06:50.607171+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-20T10:06:50.609395+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-20T10:06:55.049996+00:00 heroku[web.1]: Starting process with command `npm start`
2020-08-20T10:06:57.284172+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2020-08-20T10:06:57.284202+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2020-08-20T10:06:57.687757+00:00 app[web.1]:
2020-08-20T10:06:57.687800+00:00 app[web.1]: > notes#1.0.0 start /app
2020-08-20T10:06:57.687801+00:00 app[web.1]: > nodemon --exec babel-node src/app.js
2020-08-20T10:06:57.687802+00:00 app[web.1]:
2020-08-20T10:06:58.012979+00:00 app[web.1]: [nodemon] 1.18.10
2020-08-20T10:06:58.014501+00:00 app[web.1]: [nodemon] to restart at any time, enter `rs`
2020-08-20T10:06:58.015004+00:00 app[web.1]: [nodemon] watching: *.*
2020-08-20T10:06:58.015615+00:00 app[web.1]: [nodemon] starting `babel-node src/app.js`
2020-08-20T10:06:59.007296+00:00 app[web.1]: Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`
2020-08-20T10:07:01.309982+00:00 app[web.1]: connection error: MongoNetworkError: connection 5 to cluster0-shard-00-00.ho4na.mongodb.net:27017 closed
2020-08-20T10:07:01.309998+00:00 app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:276:9)
2020-08-20T10:07:01.310000+00:00 app[web.1]: at Object.onceWrapper (events.js:422:26)
2020-08-20T10:07:01.310000+00:00 app[web.1]: at TLSSocket.emit (events.js:327:22)
2020-08-20T10:07:01.310001+00:00 app[web.1]: at net.js:674:12
2020-08-20T10:07:01.310001+00:00 app[web.1]: at TCP.done (_tls_wrap.js:563:7) {
2020-08-20T10:07:01.310002+00:00 app[web.1]: name: 'MongoNetworkError',
2020-08-20T10:07:01.310002+00:00 app[web.1]: errorLabels: [ 'TransientTransactionError' ],
2020-08-20T10:07:01.310003+00:00 app[web.1]: [Symbol(mongoErrorContextSymbol)]: {}
2020-08-20T10:07:01.310003+00:00 app[web.1]: }
2020-08-20T10:07:01.340827+00:00 app[web.1]: [nodemon] clean exit - waiting for changes before restart
2020-08-20T10:07:55.450102+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-08-20T10:07:55.473020+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-08-20T10:07:55.500784+00:00 app[web.1]: Error waiting for process to terminate: No child processes
2020-08-20T10:07:55.575750+00:00 heroku[web.1]: Process exited with status 22
2020-08-20T10:07:55.620964+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-20T10:10:09.137371+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=favnoteback.herokuapp.com request_id=111d6959-56ad-4449-9ba6-77fa7a426577 fwd="85.221.154.50" dyno= connect= service= status=503 bytes= protocol=https
2020-08-20T10:10:10.310013+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=favnoteback.herokuapp.com request_id=dba1ddd0-36d1-44f7-886b-1e22f8ca526d fwd="85.221.154.50" dyno= connect= service= status=503 bytes= protocol=https
2020-08-20T10:11:20.182121+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=favnoteback.herokuapp.com request_id=fc425fd1-dcce-49e3-b9af-eae31c9d35f5 fwd="85.221.154.50" dyno= connect= service= status=503 bytes= protocol=https
2020-08-20T10:11:20.884144+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=favnoteback.herokuapp.com request_id=e81ab2e2-c476-494f-a2f3-2c5a3281fc55 fwd="85.221.154.50" dyno= connect= service= status=503 bytes= protocol=https
2020-08-20T10:19:21.000000+00:00 app[api]: Build started by user myemail#gmail.com
2020-08-20T10:19:47.820767+00:00 app[api]: Deploy f6a0950d by user myemail#gmail.com
2020-08-20T10:19:47.820767+00:00 app[api]: Release v14 created by user myemail#gmail.com
2020-08-20T10:19:48.014495+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-20T10:19:49.000000+00:00 app[api]: Build succeeded
2020-08-20T10:19:52.366993+00:00 heroku[web.1]: Starting process with command `npm start`
2020-08-20T10:19:55.049310+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2020-08-20T10:19:55.049332+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2020-08-20T10:19:55.560928+00:00 app[web.1]:
2020-08-20T10:19:55.560950+00:00 app[web.1]: > notes#1.0.0 start /app
2020-08-20T10:19:55.560951+00:00 app[web.1]: > nodemon --exec babel-node src/app.js
2020-08-20T10:19:55.560951+00:00 app[web.1]:
2020-08-20T10:19:55.989648+00:00 app[web.1]: [nodemon] 1.18.10
2020-08-20T10:19:55.990902+00:00 app[web.1]: [nodemon] to restart at any time, enter `rs`
2020-08-20T10:19:55.991361+00:00 app[web.1]: [nodemon] watching: *.*
2020-08-20T10:19:55.991938+00:00 app[web.1]: [nodemon] starting `babel-node src/app.js`
2020-08-20T10:19:57.234412+00:00 app[web.1]: Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`
2020-08-20T10:19:58.962557+00:00 app[web.1]: the options [useUnifiedTopology] is not supported
2020-08-20T10:19:59.745897+00:00 app[web.1]: /app/node_modules/mongodb/lib/operations/mongo_client_ops.js:474
2020-08-20T10:19:59.745912+00:00 app[web.1]: throw err;
2020-08-20T10:19:59.745913+00:00 app[web.1]: ^
2020-08-20T10:19:59.745913+00:00 app[web.1]:
2020-08-20T10:19:59.745914+00:00 app[web.1]: MongoNetworkError: connection 9 to cluster0-shard-00-00.ho4na.mongodb.net:27017 closed
2020-08-20T10:19:59.745915+00:00 app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:276:9)
2020-08-20T10:19:59.745916+00:00 app[web.1]: at Object.onceWrapper (events.js:422:26)
2020-08-20T10:19:59.745917+00:00 app[web.1]: at TLSSocket.emit (events.js:327:22)
2020-08-20T10:19:59.745917+00:00 app[web.1]: at net.js:674:12
2020-08-20T10:19:59.745917+00:00 app[web.1]: at TCP.done (_tls_wrap.js:563:7) {
2020-08-20T10:19:59.745918+00:00 app[web.1]: name: 'MongoNetworkError',
2020-08-20T10:19:59.745918+00:00 app[web.1]: errorLabels: [ 'TransientTransactionError' ],
2020-08-20T10:19:59.745919+00:00 app[web.1]: [Symbol(mongoErrorContextSymbol)]: {}
2020-08-20T10:19:59.745919+00:00 app[web.1]: }
2020-08-20T10:19:59.763100+00:00 app[web.1]: [nodemon] app crashed - waiting for file changes before starting...
2020-08-20T10:20:52.546213+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-08-20T10:20:52.568907+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-08-20T10:20:52.691301+00:00 heroku[web.1]: Process exited with status 137
2020-08-20T10:20:52.742514+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-20T10:20:52.744625+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-20T10:20:56.145248+00:00 heroku[web.1]: Starting process with command `npm start`
2020-08-20T10:20:58.152568+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2020-08-20T10:20:58.152590+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2020-08-20T10:20:58.572627+00:00 app[web.1]:
2020-08-20T10:20:58.572655+00:00 app[web.1]: > notes#1.0.0 start /app
2020-08-20T10:20:58.572656+00:00 app[web.1]: > nodemon --exec babel-node src/app.js
2020-08-20T10:20:58.572656+00:00 app[web.1]:
2020-08-20T10:20:58.948432+00:00 app[web.1]: [nodemon] 1.18.10
2020-08-20T10:20:58.949669+00:00 app[web.1]: [nodemon] to restart at any time, enter `rs`
2020-08-20T10:20:58.950054+00:00 app[web.1]: [nodemon] watching: *.*
2020-08-20T10:20:58.950608+00:00 app[web.1]: [nodemon] starting `babel-node src/app.js`
2020-08-20T10:20:59.976088+00:00 app[web.1]: Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`
2020-08-20T10:21:01.137742+00:00 app[web.1]: the options [useUnifiedTopology] is not supported
2020-08-20T10:21:01.921790+00:00 app[web.1]: connection error: MongoNetworkError: connection 8 to cluster0-shard-00-02.ho4na.mongodb.net:27017 closed
2020-08-20T10:21:01.921802+00:00 app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:276:9)
2020-08-20T10:21:01.921803+00:00 app[web.1]: at Object.onceWrapper (events.js:422:26)
2020-08-20T10:21:01.921804+00:00 app[web.1]: at TLSSocket.emit (events.js:327:22)
2020-08-20T10:21:01.921804+00:00 app[web.1]: at net.js:674:12
2020-08-20T10:21:01.921805+00:00 app[web.1]: at TCP.done (_tls_wrap.js:563:7) {
2020-08-20T10:21:01.921805+00:00 app[web.1]: name: 'MongoNetworkError',
2020-08-20T10:21:01.921806+00:00 app[web.1]: errorLabels: [ 'TransientTransactionError' ],
2020-08-20T10:21:01.921806+00:00 app[web.1]: [Symbol(mongoErrorContextSymbol)]: {}
2020-08-20T10:21:01.921807+00:00 app[web.1]: }
2020-08-20T10:21:01.933176+00:00 app[web.1]: /app/node_modules/mongodb/lib/operations/mongo_client_ops.js:474
2020-08-20T10:21:01.933178+00:00 app[web.1]: throw err;
2020-08-20T10:21:01.933178+00:00 app[web.1]: ^
2020-08-20T10:21:01.933179+00:00 app[web.1]:
2020-08-20T10:21:01.933180+00:00 app[web.1]: MongoNetworkError: connection 11 to cluster0-shard-00-02.ho4na.mongodb.net:27017 closed
2020-08-20T10:21:01.933180+00:00 app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:276:9)
2020-08-20T10:21:01.933181+00:00 app[web.1]: at Object.onceWrapper (events.js:422:26)
2020-08-20T10:21:01.933181+00:00 app[web.1]: at TLSSocket.emit (events.js:327:22)
2020-08-20T10:21:01.933182+00:00 app[web.1]: at net.js:674:12
2020-08-20T10:21:01.933182+00:00 app[web.1]: at TCP.done (_tls_wrap.js:563:7) {
2020-08-20T10:21:01.933182+00:00 app[web.1]: name: 'MongoNetworkError',
2020-08-20T10:21:01.933183+00:00 app[web.1]: errorLabels: [ 'TransientTransactionError' ],
2020-08-20T10:21:01.933183+00:00 app[web.1]: [Symbol(mongoErrorContextSymbol)]: {}
2020-08-20T10:21:01.933183+00:00 app[web.1]: }
2020-08-20T10:21:01.960242+00:00 app[web.1]: [nodemon] app crashed - waiting for file changes before starting...
2020-08-20T10:21:47.512311+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=favnoteback.herokuapp.com request_id=a0b75780-abfa-4727-99b4-cdf9bc42bb62 fwd="85.221.154.50" dyno= connect= service= status=503 bytes=
protocol=https
2020-08-20T10:21:56.438920+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-08-20T10:21:56.456159+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-08-20T10:21:56.480098+00:00 app[web.1]: Error waiting for process to terminate: No child processes
2020-08-20T10:21:56.526046+00:00 heroku[web.1]: Process exited with status 22
2020-08-20T10:21:56.561169+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-20T10:21:57.783155+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=favnoteback.herokuapp.com request_id=aa62afa9-ae33-40b3-9b54-d25bed03c5fa fwd="85.221.154.50" dyno= connect= service= status=503 bytes= protocol=https
2020-08-20T10:21:58.572293+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=favnoteback.herokuapp.com request_id=afed98ae-b48b-4d0f-944e-551cdc703571 fwd="85.221.154.50" dyno= connect= service= status=503 bytes= protocol=https
I'm very appreciated if whose help me in this Error
OK I found resolve
application could not connect with mongodb,
resolve is add 0.0.0.0/0 ip on white list in mongodb

ReferenceError: require is not defined when I push on Heroku

I want to push my NodeJS project on heroku but it doesn't work while my project works fine locally.
When I enter "heroku logs --tail" to see errors, I see :
2020-08-18T10:39:44.396002+00:00 app[web.1]: const express = require('express')
2020-08-18T10:39:44.396003+00:00 app[web.1]: ^
2020-08-18T10:39:44.396003+00:00 app[web.1]:
2020-08-18T10:39:44.396004+00:00 app[web.1]: ReferenceError: require is not defined
This is my "index.js" :
const express = require('express')
if (process.env.NODE_ENV === 'dev') require('dotenv').config()
const routerIdeas = require('./routes/ideas.js')
const PORT = process.env.PORT || 5000
const app = express()
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*")
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")
next()
})
app.use('/api', routerIdeas)
app.listen(PORT, () => {
console.log(`Server is running on port : ${PORT}`)
})
This is the complete "heroku logs --tail" :
server git:(master) heroku logs --tail
› Warning: heroku update available from 7.7.7 to 7.42.6
2020-08-18T10:17:04.311750+00:00 app[web.1]: (node:4) ExperimentalWarning: The ESM module loader is experimental.
2020-08-18T10:17:04.322224+00:00 app[web.1]: file:///app/index.js:1
2020-08-18T10:17:04.322225+00:00 app[web.1]: const express = require('express')
2020-08-18T10:17:04.322226+00:00 app[web.1]: ^
2020-08-18T10:17:04.322226+00:00 app[web.1]:
2020-08-18T10:17:04.322227+00:00 app[web.1]: ReferenceError: require is not defined
2020-08-18T10:17:04.322227+00:00 app[web.1]: at file:///app/index.js:1:17
2020-08-18T10:17:04.322228+00:00 app[web.1]: at ModuleJob.run (internal/modules/esm/module_job.js:139:37)
2020-08-18T10:17:04.322228+00:00 app[web.1]: at async Loader.import (internal/modules/esm/loader.js:179:24)
2020-08-18T10:17:04.372043+00:00 heroku[web.1]: Process exited with status 1
2020-08-18T10:17:04.401546+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-18T10:39:40.712443+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-18T10:39:42.672554+00:00 heroku[web.1]: Starting process with command `node index.js`
2020-08-18T10:39:44.381963+00:00 app[web.1]: (node:4) ExperimentalWarning: The ESM module loader is experimental.
2020-08-18T10:39:44.396000+00:00 app[web.1]: file:///app/index.js:1
2020-08-18T10:39:44.396002+00:00 app[web.1]: const express = require('express')
2020-08-18T10:39:44.396003+00:00 app[web.1]: ^
2020-08-18T10:39:44.396003+00:00 app[web.1]:
2020-08-18T10:39:44.396004+00:00 app[web.1]: ReferenceError: require is not defined
2020-08-18T10:39:44.396005+00:00 app[web.1]: at file:///app/index.js:1:17
2020-08-18T10:39:44.396005+00:00 app[web.1]: at ModuleJob.run (internal/modules/esm/module_job.js:139:37)
2020-08-18T10:39:44.396008+00:00 app[web.1]: at async Loader.import (internal/modules/esm/loader.js:179:24)
2020-08-18T10:39:44.439811+00:00 heroku[web.1]: Process exited with status 1
2020-08-18T10:39:44.472252+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-18T10:41:22.000000+00:00 app[api]: Build started by user mika77290#live.fr
2020-08-18T10:41:49.742104+00:00 app[api]: Release v6 created by user mika77290#live.fr
2020-08-18T10:41:49.742104+00:00 app[api]: Deploy 36bf1d35 by user mika77290#live.fr
2020-08-18T10:41:50.000000+00:00 app[api]: Build succeeded
2020-08-18T10:41:50.965669+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-18T10:41:53.104246+00:00 heroku[web.1]: Starting process with command `node index.js`
2020-08-18T10:41:54.814879+00:00 app[web.1]: (node:4) ExperimentalWarning: The ESM module loader is experimental.
2020-08-18T10:41:54.832290+00:00 app[web.1]: file:///app/index.js:1
2020-08-18T10:41:54.832292+00:00 app[web.1]: const express = require('express')
2020-08-18T10:41:54.832292+00:00 app[web.1]: ^
2020-08-18T10:41:54.832293+00:00 app[web.1]:
2020-08-18T10:41:54.832294+00:00 app[web.1]: ReferenceError: require is not defined
2020-08-18T10:41:54.832294+00:00 app[web.1]: at file:///app/index.js:1:17
2020-08-18T10:41:54.832294+00:00 app[web.1]: at ModuleJob.run (internal/modules/esm/module_job.js:139:37)
2020-08-18T10:41:54.832295+00:00 app[web.1]: at async Loader.import (internal/modules/esm/loader.js:179:24)
2020-08-18T10:41:54.882959+00:00 heroku[web.1]: Process exited with status 1
2020-08-18T10:41:54.911539+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-18T10:41:57.989717+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=exercice-ideas.herokuapp.com request_id=909d0f01-935e-4d95-bbf0-80e745d61559 fwd="81.249.233.246" dyno= connect= service= status=503 bytes= protocol=https
2020-08-18T10:42:08.284424+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/api/ideas" host=exercice-ideas.herokuapp.com request_id=011b8593-6112-48a0-aa6e-d4c7ab5051b5 fwd="81.249.233.246" dyno= connect= service= status=503 bytes= protocol=https
2020-08-18T10:52:39.587775+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-18T10:52:41.637962+00:00 heroku[web.1]: Starting process with command `node index.js`
2020-08-18T10:52:43.235694+00:00 app[web.1]: (node:4) ExperimentalWarning: The ESM module loader is experimental.
2020-08-18T10:52:43.250839+00:00 app[web.1]: file:///app/index.js:1
2020-08-18T10:52:43.250841+00:00 app[web.1]: const express = require('express')
2020-08-18T10:52:43.250846+00:00 app[web.1]: ^
2020-08-18T10:52:43.250846+00:00 app[web.1]:
2020-08-18T10:52:43.250847+00:00 app[web.1]: ReferenceError: require is not defined
2020-08-18T10:52:43.250847+00:00 app[web.1]: at file:///app/index.js:1:17
2020-08-18T10:52:43.250848+00:00 app[web.1]: at ModuleJob.run (internal/modules/esm/module_job.js:139:37)
2020-08-18T10:52:43.250848+00:00 app[web.1]: at async Loader.import (internal/modules/esm/loader.js:179:24)
2020-08-18T10:52:43.292178+00:00 heroku[web.1]: Process exited with status 1
2020-08-18T10:52:43.323908+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-18T11:15:25.594409+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-18T11:15:28.438563+00:00 heroku[web.1]: Starting process with command `node index.js`
2020-08-18T11:15:30.865146+00:00 app[web.1]: (node:4) ExperimentalWarning: The ESM module loader is experimental.
2020-08-18T11:15:30.883077+00:00 app[web.1]: file:///app/index.js:1
2020-08-18T11:15:30.883079+00:00 app[web.1]: const express = require('express')
2020-08-18T11:15:30.883080+00:00 app[web.1]: ^
2020-08-18T11:15:30.883081+00:00 app[web.1]:
2020-08-18T11:15:30.883081+00:00 app[web.1]: ReferenceError: require is not defined
2020-08-18T11:15:30.883081+00:00 app[web.1]: at file:///app/index.js:1:17
2020-08-18T11:15:30.883082+00:00 app[web.1]: at ModuleJob.run (internal/modules/esm/module_job.js:139:37)
2020-08-18T11:15:30.883083+00:00 app[web.1]: at async Loader.import (internal/modules/esm/loader.js:179:24)
2020-08-18T11:15:30.934853+00:00 heroku[web.1]: Process exited with status 1
2020-08-18T11:15:30.968511+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-18T11:33:00.000000+00:00 app[api]: Build started by user mika77290#live.fr
2020-08-18T11:33:34.000000+00:00 app[api]: Build succeeded
2020-08-18T11:33:34.073417+00:00 app[api]: Release v7 created by user mika77290#live.fr
2020-08-18T11:33:34.073417+00:00 app[api]: Deploy f5b59800 by user mika77290#live.fr
2020-08-18T11:33:35.255435+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-18T11:33:37.308185+00:00 heroku[web.1]: Starting process with command `node index.js`
2020-08-18T11:33:39.745180+00:00 app[web.1]: (node:4) ExperimentalWarning: The ESM module loader is experimental.
2020-08-18T11:33:39.758881+00:00 app[web.1]: file:///app/index.js:21
2020-08-18T11:33:39.758883+00:00 app[web.1]: const express = require('express')
2020-08-18T11:33:39.758884+00:00 app[web.1]: ^
2020-08-18T11:33:39.758884+00:00 app[web.1]:
2020-08-18T11:33:39.758885+00:00 app[web.1]: ReferenceError: require is not defined
2020-08-18T11:33:39.758885+00:00 app[web.1]: at file:///app/index.js:21:17
2020-08-18T11:33:39.758885+00:00 app[web.1]: at ModuleJob.run (internal/modules/esm/module_job.js:139:37)
2020-08-18T11:33:39.758886+00:00 app[web.1]: at async Loader.import (internal/modules/esm/loader.js:179:24)
2020-08-18T11:33:39.804994+00:00 heroku[web.1]: Process exited with status 1
2020-08-18T11:33:39.836710+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-18T11:33:39.838855+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-18T11:33:41.998743+00:00 heroku[web.1]: Starting process with command `node index.js`
2020-08-18T11:33:44.652533+00:00 app[web.1]: (node:4) ExperimentalWarning: The ESM module loader is experimental.
2020-08-18T11:33:44.674413+00:00 app[web.1]: file:///app/index.js:21
2020-08-18T11:33:44.674415+00:00 app[web.1]: const express = require('express')
2020-08-18T11:33:44.674415+00:00 app[web.1]: ^
2020-08-18T11:33:44.674416+00:00 app[web.1]:
2020-08-18T11:33:44.674416+00:00 app[web.1]: ReferenceError: require is not defined
2020-08-18T11:33:44.674417+00:00 app[web.1]: at file:///app/index.js:21:17
2020-08-18T11:33:44.674417+00:00 app[web.1]: at ModuleJob.run (internal/modules/esm/module_job.js:139:37)
2020-08-18T11:33:44.674418+00:00 app[web.1]: at async Loader.import (internal/modules/esm/loader.js:179:24)
2020-08-18T11:33:44.736273+00:00 heroku[web.1]: Process exited with status 1
2020-08-18T11:33:44.780957+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-18T11:33:46.586184+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=exercice-ideas.herokuapp.com request_id=af66c9bb-71fb-4575-a9b2-856ef0fd7c92 fwd="81.249.233.246" dyno= connect= service= status=503 bytes= protocol=https
I tried pushing the test project provided on the Heroku starter tutorial and there is no problem with "require", so I don't understand.
Thank you in advance to whoever can help me
I had same problem and what I did was in the package.json file I removed type:module and it worked.
I have deleted the '.git' and 'Procfile' file.
I also delete the repository on Heroku and create a new one.
I then start the procedure again to link my project to the new repository.
Then I pushed the project and now there are no more errors.
I don't understand why but it works now.

NodeJS+React+Socket.io app doesn't work on Heroku

I wrote a simple NodeJs web app using React. I use Socket.io in this app to connect client to the server. The following codes are for my server.js and the component which connects to the server :
Server.js :
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var index = require('./routes/index');
var socket = require('./common/socket');
var exphbs = require('express-handlebars');
var app = express();
require('node-jsx').install();
var port = process.env.PORT || 9091;
var io = require('socket.io').listen(app.listen(port, function(){
console.log('Server is listening on port: ' + port);
}));
io.sockets.on('connection', function(sock){
socket(sock , io);
});
io.configure(function () {
io.set("transports", ["xhr-polling"]);
io.set("polling duration", 10);
});
// view engine setup
app.engine('handlebars', exphbs({defaultLayout: 'main', extname: '.handlebars'}));
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'handlebars');
// uncomment after placing your favicon in /public
//app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', index);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
// error handlers
// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
app.use(function(err, req, res, next) {
res.status(err.status || 500);
console.log(err.message);
res.render('error', {
message: err.message,
error: err
});
});
}
// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: {}
});
});
module.exports = app;
Component.js :
'use strict';
var React = require('react');
var io = require('socket.io-client');
var socket;
var UserRow = require('./userRow');
var SimpleUserList = React.createClass({
displayName: 'SimpleUserList',
componentDidMount: function() {
socket = io.connect();
socket.on('userList', function(data) {
console.log('userlist received');
}.bind(this));
},
componentWillUnmount: function() {
socket.close();
},
render: function() {
return (<div></div>);
}
module.exports = SimpleUserList;
main.handlebars :
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="stylesheets/style.css">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
{{{ body }}}
<script src="https://cdn.socket.io/socket.io-1.0.0.js"></script>
<script src="javascripts/bundle.js"></script>
</body>
</html>
The handle bar is not important, I just wanted to show what script file I include in my html file.
Any idea why I cannot connect to the heroku server?
heroku log :
2015-07-29T10:59:30.153481+00:00 app[web.1]: > npm run-script build | node server.js
2015-07-29T10:59:30.153482+00:00 app[web.1]:
2015-07-29T10:59:39.356552+00:00 app[web.1]: /app/server.js:22
2015-07-29T10:59:39.356556+00:00 app[web.1]: io.configure(function () {
2015-07-29T10:59:39.356558+00:00 app[web.1]: ^
2015-07-29T10:59:39.356560+00:00 app[web.1]: TypeError: undefined is not a function
2015-07-29T10:59:39.356561+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:22:4)
2015-07-29T10:59:39.356565+00:00 app[web.1]: at Object.Module._extensions..js (module.js:478:10)
2015-07-29T10:59:39.356590+00:00 app[web.1]: at Module.load (module.js:355:32)
2015-07-29T10:59:39.356595+00:00 app[web.1]: at startup (node.js:129:16)
2015-07-29T10:59:39.356563+00:00 app[web.1]: at Module._compile (module.js:460:26)
2015-07-29T10:59:39.356593+00:00 app[web.1]: at Function.Module.runMain (module.js:501:10)
2015-07-29T10:59:39.356596+00:00 app[web.1]: at node.js:814:3
2015-07-29T10:59:39.356592+00:00 app[web.1]: at Function.Module._load (module.js:310:12)
2015-07-29T10:59:44.937645+00:00 app[web.1]: npm ERR! Linux 3.13.0-49-generic
2015-07-29T10:59:44.817354+00:00 app[web.1]: util.print: Use console.log instead
2015-07-29T10:59:44.932214+00:00 app[web.1]:
2015-07-29T10:59:44.938157+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2015-07-29T10:59:44.938399+00:00 app[web.1]: npm ERR! node v0.12.7
2015-07-29T10:59:44.938826+00:00 app[web.1]: npm ERR! npm v2.11.3
2015-07-29T10:59:44.939022+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2015-07-29T10:59:44.939233+00:00 app[web.1]: npm ERR! simple-user-list#0.0.0 start: `npm run-script build | node server.js `
2015-07-29T10:59:44.939499+00:00 app[web.1]: npm ERR! Exit status 1
2015-07-29T10:59:44.939661+00:00 app[web.1]: npm ERR!
2015-07-29T10:59:44.939844+00:00 app[web.1]: npm ERR! Failed at the simple-user-list#0.0.0 start script 'npm run-script build | node server.js '.
2015-07-29T10:59:44.940270+00:00 app[web.1]: npm ERR! This is most likely a problem with the simple-user-list package,
2015-07-29T10:59:44.940497+00:00 app[web.1]: npm ERR! not with npm itself.
2015-07-29T10:59:44.940649+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2015-07-29T10:59:44.940834+00:00 app[web.1]: npm ERR! npm run-script build | node server.js
2015-07-29T10:59:44.940988+00:00 app[web.1]: npm ERR! You can get their info via:
2015-07-29T10:59:44.941492+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2015-07-29T10:59:44.944584+00:00 app[web.1]:
2015-07-29T10:59:44.941149+00:00 app[web.1]: npm ERR! npm owner ls simple-user-list
2015-07-29T10:59:44.944830+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2015-07-29T10:59:44.944952+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2015-07-29T10:59:45.817817+00:00 heroku[web.1]: Process exited with status 1
2015-07-29T10:59:45.831953+00:00 heroku[web.1]: State changed from starting to crashed
2015-07-29T10:59:47.593870+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simple-user-list.herokuapp.com request_id=bd0cf3d6-0b8b-4fc0-aa37-a940cd5f328f fwd="50.19.169.132" dyno= connect= service= status=503 bytes=
2015-07-29T10:59:57.607136+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simple-user-list.herokuapp.com request_id=8f80ec43-0eb8-4375-9341-7c1c2ecb81f0 fwd="50.19.169.132" dyno= connect= service= status=503 bytes=
2015-07-29T11:00:07.626517+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simple-user-list.herokuapp.com request_id=4ee95d7b-e757-4590-b9e9-f48f491a3654 fwd="50.19.169.132" dyno= connect= service= status=503 bytes=
2015-07-29T11:00:17.650806+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simple-user-list.herokuapp.com request_id=bdebebe0-6b5b-444b-81f2-fb34d3b00bb4 fwd="50.19.169.132" dyno= connect= service= status=503 bytes=
2015-07-29T11:00:27.660163+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simple-user-list.herokuapp.com request_id=289949c3-1dac-4f3c-bb89-f6093da2c997 fwd="50.19.169.132" dyno= connect= service= status=503 bytes=
2015-07-29T11:00:37.669828+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simple-user-list.herokuapp.com request_id=997d267f-81fb-40e4-9c7d-85f9803653f8 fwd="50.19.169.132" dyno= connect= service= status=503 bytes=
2015-07-29T11:06:28.718078+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simple-user-list.herokuapp.com request_id=c0f10a34-914a-439b-8a59-5ef954d994e8 fwd="207.6.39.42" dyno= connect= service= status=503 bytes=
2015-07-29T11:10:46.273821+00:00 heroku[web.1]: State changed from crashed to starting
2015-07-29T11:10:49.577787+00:00 heroku[web.1]: Starting process with command `npm start`
2015-07-29T11:10:51.591809+00:00 app[web.1]:
2015-07-29T11:10:51.591830+00:00 app[web.1]: > simple-user-list#0.0.0 start /app
2015-07-29T11:10:51.591832+00:00 app[web.1]: > npm run-script build | node server.js
2015-07-29T11:10:51.591833+00:00 app[web.1]:
2015-07-29T11:10:57.340680+00:00 app[web.1]: /app/server.js:22
2015-07-29T11:10:57.340683+00:00 app[web.1]: io.configure(function () {
2015-07-29T11:10:57.340685+00:00 app[web.1]: ^
2015-07-29T11:10:57.340687+00:00 app[web.1]: TypeError: undefined is not a function
2015-07-29T11:10:57.340689+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:22:4)
2015-07-29T11:10:57.340692+00:00 app[web.1]: at Object.Module._extensions..js (module.js:478:10)
2015-07-29T11:10:57.340693+00:00 app[web.1]: at Module.load (module.js:355:32)
2015-07-29T11:10:57.340690+00:00 app[web.1]: at Module._compile (module.js:460:26)
2015-07-29T11:10:57.340695+00:00 app[web.1]: at Function.Module._load (module.js:310:12)
2015-07-29T11:10:57.340696+00:00 app[web.1]: at Function.Module.runMain (module.js:501:10)
2015-07-29T11:10:57.340697+00:00 app[web.1]: at startup (node.js:129:16)
2015-07-29T11:10:57.340699+00:00 app[web.1]: at node.js:814:3
2015-07-29T11:11:02.957215+00:00 app[web.1]: util.print: Use console.log instead
2015-07-29T11:11:03.080961+00:00 app[web.1]: npm ERR! Linux 3.13.0-57-generic
2015-07-29T11:11:03.088435+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2015-07-29T11:11:03.088566+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2015-07-29T11:11:03.074299+00:00 app[web.1]:
2015-07-29T11:11:03.081974+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2015-07-29T11:11:03.082248+00:00 app[web.1]: npm ERR! node v0.12.7
2015-07-29T11:11:03.082698+00:00 app[web.1]: npm ERR! npm v2.11.3
2015-07-29T11:11:03.082883+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2015-07-29T11:11:03.083205+00:00 app[web.1]: npm ERR! simple-user-list#0.0.0 start: `npm run-script build | node server.js `
2015-07-29T11:11:03.083354+00:00 app[web.1]: npm ERR! Exit status 1
2015-07-29T11:11:03.083515+00:00 app[web.1]: npm ERR!
2015-07-29T11:11:03.083669+00:00 app[web.1]: npm ERR! Failed at the simple-user-list#0.0.0 start script 'npm run-script build | node server.js '.
2015-07-29T11:11:03.084247+00:00 app[web.1]: npm ERR! not with npm itself.
2015-07-29T11:11:03.084376+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2015-07-29T11:11:03.083969+00:00 app[web.1]: npm ERR! This is most likely a problem with the simple-user-list package,
2015-07-29T11:11:03.085055+00:00 app[web.1]: npm ERR! You can get their info via:
2015-07-29T11:11:03.084565+00:00 app[web.1]: npm ERR! npm run-script build | node server.js
2015-07-29T11:11:03.085058+00:00 app[web.1]: npm ERR! npm owner ls simple-user-list
2015-07-29T11:11:03.085128+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2015-07-29T11:11:03.088091+00:00 app[web.1]:
2015-07-29T11:11:03.853402+00:00 heroku[web.1]: Process exited with status 1
2015-07-29T11:11:03.866414+00:00 heroku[web.1]: State changed from starting to crashed
2015-07-29T11:16:15.196180+00:00 heroku[slug-compiler]: Slug compilation started
2015-07-29T11:16:15.196195+00:00 heroku[slug-compiler]: Slug compilation finished
2015-07-29T11:16:15.153339+00:00 heroku[api]: Deploy a6fb15c by aryan.hosseinzadeh#gmail.com
2015-07-29T11:16:15.153339+00:00 heroku[api]: Release v15 created by aryan.hosseinzadeh#gmail.com
2015-07-29T11:16:15.571381+00:00 heroku[web.1]: State changed from crashed to starting
2015-07-29T11:16:19.908038+00:00 heroku[web.1]: Starting process with command `npm start`
2015-07-29T11:16:22.344144+00:00 app[web.1]:
2015-07-29T11:16:22.344166+00:00 app[web.1]: > simple-user-list#0.0.0 start /app
2015-07-29T11:16:22.344168+00:00 app[web.1]: > npm run-script build | node server.js
2015-07-29T11:16:22.344170+00:00 app[web.1]:
2015-07-29T11:16:28.997464+00:00 app[web.1]: Option polling duration is not valid. Please refer to the README.
2015-07-29T11:16:29.378774+00:00 heroku[web.1]: State changed from starting to up
2015-07-29T11:16:29.671752+00:00 app[web.1]: Server is listening on port: 9807
2015-07-29T11:16:30.880399+00:00 heroku[router]: at=info method=GET path="/" host=simple-user-list.herokuapp.com request_id=8286e365-9790-487e-9b71-a69a4de800fc fwd="54.144.80.213" dyno=web.1 connect=6ms service=227ms status=200 bytes=2017
2015-07-29T11:16:30.910262+00:00 app[web.1]: GET / 200 252.009 ms - 1821
2015-07-29T11:16:34.120554+00:00 app[web.1]: util.print: Use console.log instead
So , it's solved.
There was no need to explicitly refer to {host}/socket/socket.io and there was no need to specify io.config (at least so far) and also there was no need to specify host address on client side (io.connect is good enough).

Resources