When uploading a script file, users may encounter the error {"type":"error.SuiteScriptModuleLoaderError","name":"UNEXPECTED_ERROR","message":"missing ; before statement() stack":[]}. This issue often arises when scripts utilize classes and the NApiVersion is not properly set. Fortunately, there is a straightforward solution to rectify this error.
To address the "missing ; before statement()" error, it is crucial to ensure that the NApiVersion is set to 2.1. This version is specifically designed to support scripts that make use of classes. Below is an example illustrating how to set the NApiVersion to 2.1:
/** * @NApiVersion 2.1 * @NScriptType UserEventScript * @NModuleScope SameAccount */define(['N/error','N/currentRecord'],function(error,currentRecord) {});
By explicitly setting the NApiVersion to 2.1 as demonstrated in the example above, scripts can effectively utilize classes without encountering the error during the upload process. This ensures smoother script execution and mitigates any potential issues related to class usage in NetSuite SuiteScript development.
To know more about deploying SuiteScript, check these New to NetSuite Articles.
Do you have another way on how to resolve Script Upload Error: "missing ; before statement()"? Feel free to share them here!
If you find this information useful, let us know by reacting or commenting on this post! Thank you!