Search code examples
meteordeploymentservermeteor-up

process.env.PWD doesn't work on mupx deploy


I have this code in my Meteor project on the server. It loads a font file into a PDF generating package:

doc.font(process.env.PWD + '/public/[...]');

This works fine on my local machine but in deployment I get this error logged:

Error: ENOENT, no such file or directory '/bundle/bundle/public/[...]'

The PDF package is using fs.readFileSync to try and read this file.

I'm deploying using mupx [the dev branch of Meteor Up which uses Docker].

Why would process.env.PWD no longer correctly reference the correct root of my project? Is the issue related to the build scripts that mup[x]/Meteor does to create production versions of Meteor apps?


Solution

  • I can't find how to do this / perhaps there is not a Meteor way to do this yet. So my current solution is to check for production/development and set a variable for the prefix:

    if (process.env.NODE_ENV === 'development') {
      prefix = process.env.PWD + '/public';
    } else {
      prefix = '/bundle/bundle/programs/web.browser/app';
    }
    

    This prefix variable gets you to /public