0

Railway error

1

I decided to host my website(made on express.js) on railway. But i get Error: Cannot find module './models/product'. Even if it works on localhost

How directory looks

2

Why this is happening ? And how can i fix it ?

But this wont happen on localhost. And no matter how ill try to change path to index.js it won`t work.

ESAR0
  • 1
  • 2

1 Answers1

0

The problem was when choosing the PORT to connect. Railway.com hosting needs an .env variable to choose which port to use. I hadn't written this, so hosting returned an error. This is how it was resolved:

app.listen(process.env.PORT || 3000, () => {
    console.log("On work")
})
tdy
  • 36,675
  • 19
  • 86
  • 83
ESAR0
  • 1
  • 2