-
Notifications
You must be signed in to change notification settings - Fork 126
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
Support locally installed puppeteer #19
Comments
Hello @KylePDavis , I think However, it's quite hard to require puppeteer globally because it's hard to find the path of where it is installed. Apparently Therefore, my plan is to let user enter the path of const engine = new mume.MarkdownEngine({
filePath: "/Users/wangyiyi/Desktop/markdown-example/test3.md",
config: {
previewTheme: "github-light.css",
puppeteerPath: "/usr/local/node_modules/puppeteer"
}
}) What do you think? |
Thanks for the quick response! I definitely think that In my case, I'm trying to use Your idea for providing an option for where I'm thinking something as simple as trying to resolve against a list of paths. Then maybe if there are still edge cases you could allow them to override that list of module directories but hopefully that won't be necessary. What about trying the list of paths provided by the global-paths package? Then you could do something like this: const path = require('path');
const getGlobalPaths = require('global-paths');
function requireFromPaths(id, paths) {
for (let p of paths) {
try { return require(path.join(p, id)); } catch(err) { /* next... */ }
}
throw new Error(`Unable to load "${id}" from: ${paths.join(',')}`)
}
// ... some where later in the code ...
puppeteer = requireFromPaths('puppeteer', getGlobalPaths()); |
Hi @KylePDavis , This issue should be fixed now. Please check this line. Thanks |
Hey @shd101wyy, thanks for looking into this. It looks like that code forces global module resolution but here I actually need the ability to use the standard local module resolution. It would be much better for me if I could simply use the version of In other words, I want to prefer local modules first but then fallback to global modules. I see two viable approaches here:
Long-term I think approach [2] is better but short-term I could make approach [1] work if you would rather do that instead. Even longer-term it might even make sense to do both approach [2] and approach [1]. Does that better explain what I'm after here? |
It would be great if you can submit me a pull request. |
The PDF generation via Chrome is great but I would like to package
puppeteer
locally instead of being required to have it installed globally (this can problematic in some scenarios).It looks like the initial implementation used the
requireg
package and was then adjusted to with a simpler local implementation in PR #9 due to some macOS compatibility issues.Maybe if we could get a little closer to the original
requireg
implementation we could allow for localpuppeteer
installations as well. If we change thechromeExport()
method to try a nativerequire('puppeteer')
first and then use the current global check as a fallback then we could support both cases (see src/markdown-engine.ts#L1364-L1370).Thoughts?
The text was updated successfully, but these errors were encountered: