-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Error: ENOENT: no such file or directory, open '//data.trie' #990
Comments
I've been having the exact same problem, are you also using Typescript? Disabling Typescript solved it for me. I know it's not a viable solution in most cases, but it might point somewhere. |
Same problem for me, I will get back here if I find a solution. |
I have an issue with webpacked solution
Although works fine on dev machine with Any solutions for it? |
There's some error in your webpack configuration You can look here a working webpack configuration: https://github.com/blikblum/pdfkit-webpack-example Alternatively you can use https://www.npmjs.com/package/pdfkit-next that is browser friendly |
I'm actually not using it in browser, I'm using it on node.js installation. Althout I want to public some minimal distribution instead of sharing 200mb of dependencies. I can't share my config now but I can do it tomorrow. |
@blikblum I see your solution but none of them was working for me. I'm also getting this error:
I'm creating a lambda using Typescript, serverless; scaffholding through temaplate: This is the webpack.config.js (which is the default from the above aws-nodejs-typescript template): `const path = require('path'); const entries = {}; Object.keys(slsw.lib.entries).forEach( module.exports = { |
You need add brfs transform. See config of the example i linked above |
Here is my repo: https://github.com/Pzixel/PDFKit-example.git As you can see I add "brfs" transformation. However, it doesn't work to me: |
You are applying brfs to ts files. You should create a specific rule for js files. |
I didn't (if you can see there was JS rules), and adding TS files to rule set doesn't change it (see most recent commit). So it still doesn't work. I'd appreciate if you clone the repo and make sure it doesn't work. You could add some fixed there so everybody could find out how to fix the issue. |
I'm having this exact problem as well, when trying to use the module on a webpacked node.js server. |
I created a PR fixing Pzixel/PDFKit-example#1 webpack try to use es module version even on node which brfs does not supports. brfs also dont like babel interopDefault helper |
If anyone is looking for a simple temporary solution, you can download the standalone js file at https://github.com/foliojs/pdfkit/releases/download/v0.10.0/pdfkit.standalone.js Then just require that in code. |
Looks like you found a solution, however that repo is no longer public - do you have any details of what the solutions was? |
I actually didn't manage to make it work with webpack so I don't pack it. I decided that extra 50mb in docker image is better than spending days for a solution. I wonder why repo is missing. Did I delete it by accident? Going to ask support if they could restore it. Support helped me to restore the repository, now it's available |
In case someone hits this issue in the future. I was able to address this error by adding the following to the module.rules in the repo/webpack.config https://github.com/Pzixel/PDFKit-example.git {test: /unicode-properties[/\]unicode-properties.cjs.js$/, loader: "transform-loader?brfs"}, The primary issue for me was that webpack was using the es, not cjs file for unicode-properties/unicode-properties.cjs.js and in turn not inlining the data.trie file contents via the transform-loader?brfs |
I was finally able to get this working server side with webpack using config from the example webpack.config at Pzixel/PDFKit-example.git as mentioned above although I had to add all of the following:
You need to npm/yarn install |
Dude, you saved my day! |
A webpack 5 example can be found at https://github.com/foliojs/pdfkit/tree/master/examples/webpack |
From anyone coming here with an Nx.dev project that is building a stand-alone nodejs script, I had trouble getting any of the above solutions to work as they were when trying to generate main.js with all externalDependecies packaged (externalDependencies: "none"). The final config that worked for me: webpack.config.js
project.json
Dependencies / package.json
|
Question
Error while loading
How to solve this?
Error: ENOENT: no such file or directory, open '//data.trie'
Code sample
const PDFDocument = require('pdfkit');
const fs = require('fs');
const doc = new PDFDocument();
export class PdfStreamDataService {
constructor() {
}
}
Your environment
The text was updated successfully, but these errors were encountered: