
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.
Frequently Asked Questions
Need help with your NetSuite project?
Whether it's integrations, customization, or support — let's talk about how we can help.

Martina Karszensztejn
Senior Backend Developer
Senior Backend Developer at BrokenRubik building robust server-side solutions and NetSuite integrations. Specializes in API development, data processing, and system optimization.
Get More Insights Like This
Join our newsletter for weekly tips, tutorials, and exclusive content delivered to your inbox.
Related Articles
Acumatica vs NetSuite: Which Cloud ERP Fits Your Business?
Acumatica vs NetSuite comparison covering pricing models, deployment options, manufacturing, and when each ERP is the better choice for mid-market companies.
Best NetSuite Apps & SuiteApps: Top Applications for 2026
Discover the best NetSuite apps from the SuiteApp marketplace. Curated list of top SuiteApps and SuiteCloud platform extensions that extend NetSuite for SDN partners and businesses.
BrokenRubik Is Now a Celigo Standard Partner
We are excited to announce our promotion to Celigo Standard Partner — a milestone that reflects our growing expertise in iPaaS integrations and our commitment to delivering reliable, scalable solutions for our clients.
Martina Karszensztejn