Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdfkit errors #2

Closed
rauchg opened this issue Nov 13, 2018 · 4 comments
Closed

pdfkit errors #2

rauchg opened this issue Nov 13, 2018 · 4 comments
Assignees

Comments

@rauchg
Copy link
Member

rauchg commented Nov 13, 2018

ncc version: 0.22

Source:

const fs = require("fs");
const PDFDocument = require("pdfkit");
const doc = new PDFDocument();
doc.fontSize(15).text("Hi there", 50, 50);
doc.pipe(fs.createWriteStream("out.pdf"));
doc.end();

Expected:

No output, working pdf:

▲  play-ncc/ node index.js
▲  play-ncc/

image

Received:

▲  play-ncc/ node out.js
internal/modules/cjs/loader.js:589
    throw err;
    ^

Error: Cannot find module 'iconv-lite'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:587:15)
    at Function.Module._load (internal/modules/cjs/loader.js:513:25)
    at Module.require (internal/modules/cjs/loader.js:643:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/Users/rauchg/Projects/play-ncc/out.js:1:270)
    at Module._compile (internal/modules/cjs/loader.js:707:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
    at Module.load (internal/modules/cjs/loader.js:605:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
    at Function.Module._load (internal/modules/cjs/loader.js:536:3)

Compilation output:

▲  play-ncc/ ncc index.js -o out.js
'iconv-lite' is imported by node_modules/fontkit/index.js, but could not be resolved – treating it as an external dependency
'iconv-lite' is imported by node_modules/restructure/src/DecodeStream.js, but could not be resolved – treating it as an external dependency
'iconv-lite' is imported by node_modules/restructure/src/EncodeStream.js, but could not be resolved – treating it as an external dependency
'iconv-lite' is imported by commonjs-external:iconv-lite, but could not be resolved – treating it as an external dependency
Circular dependency: node_modules/pdfkit/js/object.js -> node_modules/pdfkit/js/reference.js -> node_modules/pdfkit/js/object.js
Circular dependency: node_modules/pdfkit/js/object.js -> node_modules/pdfkit/js/reference.js -> commonjs-proxy:/Users/rauchg/Projects/play-ncc/node_modules/pdfkit/js/object.js -> node_modules/pdfkit/js/object.js
Circular dependency: node_modules/pdfkit/js/font.js -> node_modules/pdfkit/js/font/standard.js -> node_modules/pdfkit/js/font.js
Circular dependency: node_modules/pdfkit/js/font.js -> node_modules/pdfkit/js/font/standard.js -> commonjs-proxy:/Users/rauchg/Projects/play-ncc/node_modules/pdfkit/js/font.js -> node_modules/pdfkit/js/font.js
Circular dependency: node_modules/pdfkit/js/font.js -> node_modules/pdfkit/js/font/embedded.js -> node_modules/pdfkit/js/font.js
@rauchg
Copy link
Member Author

rauchg commented Nov 14, 2018

Still a problem with @zeit/[email protected]

/Users/rauchg/Projects/nda/out.js:1
(function (exports, require, module, __filename, __dirname) { "use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var string_decoder=_interopDefault(require("string_decoder")),buffer=_interopDefault(require("buffer")),stream=_interopDefault(require("stream")),util=_interopDefault(require("util")),events=_interopDefault(require("events")),zlib=_interopDefault(require("zlib")),fs=_interopDefault(require("fs")),commonjsGlobal="undefined"!=typeofwindow?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function unwrapExports(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}function getCjsExportFromNamespace(e){return e&&e.default||e}var key,reference=createCommonjsModule(function(e){(function(){var t,r,n,i,a=function(e,t){return function(){return e.apply(t,arguments)}},o={}.hasOwnProperty;i

TypeError: Cannot read property 'prototype' of undefined
    at /Users/rauchg/Projects/nda/out.js:1:1029768
    at /Users/rauchg/Projects/nda/out.js:1:1029820
    at /Users/rauchg/Projects/nda/out.js:1:1031922
    at /Users/rauchg/Projects/nda/out.js:1:1031939
    at createCommonjsModule (/Users/rauchg/Projects/nda/out.js:1:728)
    at Object.<anonymous> (/Users/rauchg/Projects/nda/out.js:1:1029348)
    at Module._compile (internal/modules/cjs/loader.js:707:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
    at Module.load (internal/modules/cjs/loader.js:605:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:544:12)

@rauchg rauchg changed the title pdfkit errors pdfkit errors Nov 14, 2018
@guybedford
Copy link
Contributor

This sounds like the circular reference issue as well (possible dupe of #10 depending on how we solve these).

@guybedford
Copy link
Contributor

Code in question here is exactly -

  var AFMFont, PDFFont, StandardFont, fs$$1,
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

so it does seem like a cycle bug to me. Adding cycle label.

@rauchg
Copy link
Member Author

rauchg commented Nov 24, 2018

Fixed by #39

@rauchg rauchg closed this as completed Nov 24, 2018
@ninja- ninja- mentioned this issue Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants