process.env.PWD在mupx部署上不起作用 [英] process.env.PWD doesn't work on mupx deploy

查看:253
本文介绍了process.env.PWD在mupx部署上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Meteor项目中有这个代码在服务器上。它将字体文件加载到PDF生成程序包中:



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



这个工作在我的本地机器上运行正常,但在部署中我收到了这个错误记录:



错误:ENOENT,没有这样的文件或目录'/ bundle / bundle / public /[...]'



PDF包正在使用fs.readFileSync尝试读取此文件。



我正在使用mupx [Meteor的开发分支使用Docker]。



为什么process.env.PWD不再正确引用我的项目的正确根目录?这个问题是否与mup [x] / Meteor制作的Meteor应用程序的制作版本相关?

解决方案

找不到如何做到这一点/也许没有一个流星的方式来做到这一点。所以我目前的解决方案是检查生产/开发,并为前缀设置一个变量:

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

这个前缀变量让你到/ public


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?

解决方案

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

这篇关于process.env.PWD在mupx部署上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆