3

I am trying to deploy a Node app on an Azure App Service, using Github and Kudu, running on Windows. The deployment works and the app is started.

My codebase is organised as follows:

/config
/res
/src
package.json

and package.json contains node src/start.js.

The problem I am having is that it seems that on that deployment the root directory for the Node app is site/wwwroot/src and not (as on my local machine, or my previous deployment on AWS) site/wwwroot. This leads to my code not finding the files inside /config or /res since the paths used in the code presume that the root is top level, and not inside /src (e.g. ./res/myFile.jpg will try opening site/wwwroot/src/res/myFile.jpg and not site/wwwroot/res/myFile.jpg).

I have been looking around but can't find how to change this. Can anyone help me?

Thanks!

Joris Mans
  • 6,024
  • 6
  • 42
  • 69
  • How are you referencing the files (e.g. ./, __dirname)? I'm referencing this post: https://stackoverflow.com/questions/8131344/what-is-the-difference-between-dirname-and-in-node-js. – Mitch Stewart Apr 12 '19 at 17:45
  • like this for instance: 'res/informationInquiryInternalMail.hbs' – Joris Mans Apr 12 '19 at 18:41
  • The problem also is that I use a library that searches configuration files depending on environment variable settings, and that it searches those relative to the project root. So in that case I can't fix it by using __dirname since it is out of my control. In all the time I used AWS I never encountered this problem. – Joris Mans Apr 12 '19 at 18:43

1 Answers1

1

For those wondering: I didn't solve it but a workaround is to put your entrypoint js file in the root directory. So instead of having node src/index.js you use node index.js, while keeping all your other sources in /src.

Joris Mans
  • 6,024
  • 6
  • 42
  • 69