0

I've got an MVC application using Nodejs / Express.

If I start the app using PM2 within the directory EG.

pm2 start my_app.js

All is well. If I try to start it from another directory EG.

pm2 start ../another_directory/my_app.js

The app appears to start fine, but when I browser the app it complains it can't find the view file. The error implies it's looking for the view file in the directory (EG my_folder/views I'm sat in, instead of ./another_directory/views/my_view.

Sorry this is a bit general. But does this ring a bell with anybody please?

Thanks.

Edit. Would setting a Express namespace solve this issue as per:

Setting an Express namespace

Edit 2. It didn't help.

Strontium_99
  • 1,771
  • 6
  • 31
  • 52

1 Answers1

0

If anybody is interested, I solved it by adding the following to my start uo .js script I was calling:

app.set('views', `${__dirname}/views`);

Seems I had to reinforce the path to the views.

Strontium_99
  • 1,771
  • 6
  • 31
  • 52