Introduction
Sometimes we need to build backend Script functionalities that require external libraries to simplify complex tasks.
For example: NetSuite does not provide a native way to read Excel .XLSX files (the most common modern format). To handle these files, we need a library such as XLSX.js that can interpret Excel content.
What are the challenges?
Before the standardization of ES Modules in ECMAScript 6, there was no single, unified way to modularize and distribute libraries. Instead, different (and often incompatible) systems were used.
NetSuite backend scripts in SuiteScript 2.x rely on AMD. However, not all libraries are distributed in this format. In fact, CommonJS and ESM are far more common today, which makes direct integration with SuiteScript more difficult.
Limitations
Not every library can be used in NetSuite. The issue is not the distribution format itself but rather the runtime that NetSuite uses: GraalVM JavaScript.
This runtime does not support:
Browser-specific objects (window, document, etc.)
Native Node.js modules
The fetch API
If a library depends on these features, it cannot be used in a backend Script.
How to Import a Non-AMD Library
To demonstrate, we’ll use Zod, a schema validation library. We’ll bundle it into AMD format so it can be used in a Suitelet.
The same process applies to other backend scripts and almost any library* (see Limitations above).
Step 1. Prepare Your Environment
Make sure you are inside a Node.js project (you should see a package.json file in your directory).
Install the library you want. For Zod:
Install Rollup, the bundler we’ll use:
If your library is distributed in CommonJS, you’ll also need Rollup’s CommonJS plugin:
Step 2. Create the Rollup Config File
Create a file named rollup.config.mjs in your project folder. Add the following configuration:
input → Path to the library’s entry file (usually inside node_modules). For Zod, it’s ./node_modules/zod/lib/index.js.
output.file → Name of the bundled file to generate. In this case: zod.js.
format → Must be amd to work in NetSuite.
Step 3. Run the Build
With the config file ready, run Rollup:
This will produce the output file (zod.js in our example).
Step 4. Upload to NetSuite
Upload the generated zod.js file into the File Cabinet of your NetSuite account. From there, you can reference and import it in your backend Scripts just like any other module.
Conclusion
Although NetSuite doesn’t natively support every library format, using a bundler like Rollup allows you to convert CommonJS or ESM libraries into AMD modules compatible with SuiteScript 2.x.
By doing so, you unlock access to powerful tools like Zod, XLSX.js, and many others, enabling you to write cleaner, more efficient, and more capable backend scripts.
Need help implementing external libraries or optimizing your SuiteScript projects? At BrokenRubik, we specialize in SuiteCommerce and NetSuite customizations that scale. Contact us to see how we can support your team.

Martina Karszensztejn
Senior Backend Developer
Senior Backend Developer building robust server-side solutions.
Get More Insights Like This
Join our newsletter for weekly tips, tutorials, and exclusive content delivered to your inbox.
Related Articles
How BrokenRubik uses NetSuite to support tariff-affected businesses
Navigating tariff complexity through tailored NetSuite architecture, automation, and cross-border integrations.
Make the most of SuiteWorld 2025 with BrokenRubik
Get ready for SuiteWorld 2025 with BrokenRubik: key trends, insights, and strategies to make the most of NetSuite’s flagship event.
Monitoring NetSuite: Best practices to prevent errors and boost performance
A guide to logging, performance analysis, and proactive monitoring for more stable NetSuite implementations
Martina Karszensztejn