Test an Extension on a Local Server

You can test your extension customizations on a local server before deploying to NetSuite. The local server is installed as part of the Node.js installation and uses the Express web framework.

gulp extension:local

This command compiles all source files into combined files within a LocalDistribution/tmp directory.

When the server starts, Gulp.js initializes watch tasks that listen for changes to files in the JavaScript, Templates, or Sass directories. When you save changes to a file, gulp automatically recompiles the source files and updates the LocalDistribution directory. Gulp also outputs a message to the console when an update occurs.

Important:

Typically, you test your code locally before deploying to a live site in a NetSuite account. However, if you are developing an extension that includes SuiteScript or configuration (JSON) files, you must deploy your files to your account and activate the extension for these changes to accessible by the local server. SuiteScript includes services, which do not exist in your account’s backend until you deploy them. Likewise, changes to configuration JSON files do not apply to a domain until deployed. See Manage Themes and Extensions.

Note:

If you modify any manifest files, you must restart your local server to see changes.

To test your extension on a local server:

  1. If you have not already done so, fetch the active theme.

    This is required before you can test an extension locally. See Fetch Active Theme and Extension Files for details.

  2. Open a command line or terminal and access the top-level development directory. This is the same directory created when you extracted the Extension Developer Tools.

  3. Run the following command:

    gulp extension:local

    If this is the first time you are running gulp extension:local in this directory, this command creates a subdirectory called LocalDistribution. It then compiles the source files and outputs them to this directory.

    Warning:

    Potential data loss. Besides compiling and deploying your extension to a local server, the gulp extension:local command updates the manifest.json file for the extension. This action overwrites any manual changes you made to this file. To preserve any manual changes to your manifest.json file, run the gulp extension:local --preserve-manifest command instead. See Edit the Extension Manifest for details on this file.

  4. Navigate to the local version of the application using one of the following URLs:

    • Shopping: http://<DOMAIN_NAME>/c.<ACCOUNT_ID>/<SSP_APPLICATION>/shopping-local.ssp

    • My Account: http://<DOMAIN_NAME>/c.<ACCOUNT_ID>/SSP_APPLICATION/my_account-local.ssp

    • Checkout: http://<DOMAIN_NAME>/c.<ACCOUNT_ID>/SSP_APPLICATION/checkout-local.ssp

    In the above URL patterns, you must replace the following variables with values for your specific environment:

    DOMAIN_NAME

    Replace this value with the domain name configured for your NetSuite website record.

    For example: http://www.mysite.com

    ACCOUNT_ID

    Replace this value with your NetSuite account ID.

    For example: c.123456

    SSP_APPLICATION

    Replace this value with the URL root that you are accessing.

    For SuiteCommerce implementations, this variable should read scs.

    For SuiteCommerce Advanced (SCA), this variable equals the URL root of the SCA implementation.

    SuiteCommerce example: scs

    SuiteCommerce Advanced examples:

    • sca-dev-aconcagua

    • sca-dev-2019–2–0

    Complete URLs for SuiteCommerce implementations would look like these examples:

    • http://www.mysite.com/c.123456/scs/shopping-local.ssp

    • http://www.mysite.com/c.123456/scs/my_account-local.ssp

    Complete URLs for SuiteCommerce Advanced implementations would look like these examples:

    • http://www.mysite.com/c.123456/sca-dev-aconcagua/shopping-local.ssp

    • http://www.mysite.com/c.123456/sca-dev-2019–2–0/shopping-local.ssp

    Note:

    When accessing the secure checkout domain using HTTPS on the local server, you must use a different URL. See Secure HTTP (HTTPS) with the Local Server for more information.

Related Topics

Test and Deploy Your Extension
Deploy an Extension to NetSuite

General Notices