我收到未找到错误Phantom-pdf配方的错误,然后在使用jsreport节点模块时出现另一个错误 [英] I get Error Phantom-pdf recipe was not found and then another error when using jsreport node module

查看:118
本文介绍了我收到未找到错误Phantom-pdf配方的错误,然后在使用jsreport节点模块时出现另一个错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行此命令时出现错误

GET /pdfreport - - ms - -
WARRNING! '$data.ObjectID' not supported as computed Key!
WARRNING! '$data.ObjectID' not supported as computed Key!
WARRNING! '$data.ObjectID' not supported as computed Key!
WARRNING! '$data.ObjectID' not supported as computed Key!
WARRNING! '$data.ObjectID' not supported as computed Key!
Recipe phantom-pdf was not found.
GET /pdfreport - - ms - -
{ [Error: ENOENT, unlink '/var/folders/r0/l6_3z9g55x95s7dp34yt3scw0000gn/T/xcrun_db']
  errno: 34,
  code: 'ENOENT',
  path: '/var/folders/r0/l6_3z9g55x95s7dp34yt3scw0000gn/T/xcrun_db' }

我有这样的节点来表示路由设置:

I have my node express route setup like this:

app.route('/pdfreport')
    .get(function (req, res) {

        var jsreport = require('jsreport');
        jsreport.bootstrapper(jsreport.renderDefaults).start().then(function(conf) {
                conf.reporter.render({
                    template: {
                        content: "<h1>Hello world</h1>",
                        phantom: {
                            header: "<p>some header</p>",
                            orientation: "portrait",
                            width: "300px"
                        }
                    }
                }).then(function(out) {
                    out.result.pipe(res);
                }).fail(function(e) {
                    console.log(e);
                });
        });
    });

我不确定如何解决此错误.我在网上寻找未找到配方phantom-pdf的信息.

I am not sure how to resolve this error. I have looked online for the Recipe phantom-pdf was not found.

推荐答案

此问题在最新的0.2.3版本中已修复,只需执行npm install jsreport并且它应该可以工作.

This is fixed in the latest 0.2.3 version, just do npm install jsreport and it should work.

一些提示:

您应该打开记录器以调查这些问题:

You should turn on logger to investigate these issues:

jsreport.renderDefaults.logger.providerName = "console";

如果没有理由,则不应为每个请求引导jsreport.您也许可以考虑使用为您缓存单个实例的渲染快捷方式:

You should not bootstrap jsreport for every request if there is no reason for it. You can maybe consider using a render shortcut which cache single instance for you:

app.route('/pdfreport')
    .get(function (req, res) {
        require('jsreport').render({
                    template: {
                        content: "<h1>Hello world</h1>",
                        phantom: {
                            header: "<p>some header</p>",
                            orientation: "portrait",
                            width: "300px"
                        }
                    }
                }).then(function(out) {
                    out.result.pipe(res);
                }).fail(function(e) {
                    console.log(e);
                });
  });

文档位于此处

这篇关于我收到未找到错误Phantom-pdf配方的错误,然后在使用jsreport节点模块时出现另一个错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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