When I deployed my Node project that uses express/mongoose
to Heroku and looked at the logs it showed
Error: Cannot find module '../models/Posts'
Which is required in my index.js file as
const Posts = require('../models/Posts');
This path works for me when testing on a local server. I can temporarily fix this by moving the model to the same folder as index.js
and changing the path to const Posts = require('./models/Posts');
.
It looks like Heroku is having trouble interpreting the ../
’s in my path correctly. Is there a fix for this?
"/app/models/Posts"
but I still getError: Cannot find module '/app/models/Posts'