Alternatively, configure npm to use your corporate registry or proxy, then install using the standard command.
Minimal JavaScript app example
Once you have installed the GroupDocs.Total package, here’s a minimal example of how you can use it in a Node.js application.
Create a JavaScript file (e.g., app.js) in your project’s root directory.
Import the GroupDocs.Total module and implement a simple file viewing functionality:
import{Viewer}from'@groupdocs/groupdocs.total';importjavafrom'java';constHtmlViewOptions=java.import('com.groupdocs.viewer.options.HtmlViewOptions');// Path to the file you want to render
constfilePath='contract.docx';// Initialize viewer
constviewer=newViewer(filePath);// Render the file to HTML
viewer.view(HtmlViewOptions.forEmbeddedResources());viewer.close();process.exit(0);
contract.docx is the sample file used in this example. Click here to download it.
Run the app by executing the following command in your terminal:
node app.js
This minimal example converts a document to HTML format. The output will contain rendered pages in HTML format.
Note
Always import @groupdocs/groupdocs.total before calling java.import(...). Main entry points such as Viewer and Converter are exported from the package; options and helper classes live in the suite JAR and are loaded with java.import('fully.qualified.ClassName').
Troubleshooting installation
node-gyp toolchain not found: install the required build tools for your OS (see System Requirements).
Java not detected: set JAVA_HOME and add <JAVA_HOME>/bin to PATH.
Corporate proxy: configure npm proxy settings before running install. Allow HTTPS access to GroupDocs release storage if the library download fails during install.
Permission errors: ensure you have write access to the project directory and cache folders.
java.import(...) returns null / ClassNotFound: import @groupdocs/groupdocs.total first; use the full Java class name.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.