2

I know that ArcGIS Web AppBuilder Desktop is built using Node.js

Is there any way we can add the third party node.js modules in Web AppBuilder Desktop using the npm command and then access these modules in the custom widget?

For example, I would like to use the npm module: https://www.npmjs.com/package/xlsx In a custom widget

Where do I write the command to download the module?

After downloading the module how do I access it in the custom widget?

1

From the Web AppBuilder documentation:

There are three ways to load a third-party library in Web AppBuilder for ArcGIS. Depending on the library and the purpose of your app, choose one of the following to load it:

  • Put the library in the resources array defined in the init.js file. The third-party JavaScript library or CSS library can be loaded in this way. All resources in the resources array are loaded first by the loadResource method when the app loads. Keep the following in mind:
    • The loadResource method does not ensure the loading order. As a result, the third-party library may be loaded before or after ArcGIS API for JavaScript.
    • Use this approach when you want to load a non-AMD module shared with more than one widget. However, it does not apply to AMD modules.
  • Put the library in the libs folder and add it to the libs/main dependency array. Use this approach to load a shared AMD module.
  • Put the library in the widget or theme folder and add it to your widget or theme dependency array. Use this approach to load an AMD module that only applies to one widget or theme.

One approach could be using the npm install command specifying the installation folder using the --prefix option (for an example take a look at: https://stackoverflow.com/a/14469516/7144368).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.