1

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?

Giacomo1968
  • 58,727
Brendan
  • 11

1 Answers1

0

It turns out that I had a bunch of console.log()s in my routes(index.js). Removing them fixed the problem.

Giacomo1968
  • 58,727
Brendan
  • 11