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
Mis-detecting Existence of Node.js #277
Comments
Apologies in advance if this is a little vague, I'm trying to come up with a workable solution for my current project. Will update this when I can. |
Hi @adrianirwin, I understand what you're saying, and i'm not against improving node detection, however, There's only two ways to save files:
The Can you use that or are you facing the opposite issue where you need to force node? |
I ran into a similar problem (mis-detects as node) trying to use pptxgenjs with Ember. Although you mentioned that NodeJS is only used for saving, it still causes problems (i.e. exceptions) in the client code when the lib is imported, due to the require('jquery-node') in the code at the end of pptxgen.js below. Since we're running in the browser there is no jquery-node module.
|
Yikes, I didn't consider the potential for clobbering libraries and/or causing exceptions when the library goes to load Node dependencies. I needed to update Node detection anyway, so i've updated the code to check for Thanks for the feedback. Let me know if the new version works better once the newest NPM version is released. |
I copied the change you made into my local copy to see how it worked. If I imported it in Ember in one way, it would detect as node, but as browser if I used a diff import method. Ember allows you to import things directly out of your node_modules (e.g. like
If I made it globally available as per https://guides.emberjs.com/v2.18.0/addons-and-dependencies/managing-dependencies/#toc_other-assets, however, it correctly detects as browser. I'm wondering if perhaps we could defer any decisions related to environment (node / browser) as late as possible, so that there is an opportunity to call setBrowser before that happens and then take the appropriate steps. Perhaps this would solve some of the issues people have seen with other frameworks misdetecting? |
Hi @DSheffield, I've removed the electron detection library and made the loading of library dependencies more robust using try/catch. This will fix the error with loading of So, you're using this now? If so, do you mind trying with the new changes: Change Commit |
@gitbrent , I tried the change but it still results in this error when I try to save a presentation from the sample.
|
Hi @SSS2557 , What version on PptxGenJS are you using? |
The determination of whether Node.js is present or not is made here (line 54, pptxgen.js)
var NODEJS = ( typeof module !== 'undefined' && module.exports );
However, it is not foolproof, and can lead to a false positive, as it will also pass when CommonJS is present. Please review this thread from Stack Overflow for a possible solution.
The text was updated successfully, but these errors were encountered: