web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Is it possible to reference nodejs in a javascript web resource

(2) ShareShare
ReportReport
Posted on by 101

I am trying to load a module using the require() function into my script.  I don't know if it's possible to reference nodejs in a web resource.  I haven't found any documentation on this.  If there is another way to load a module with vanilla javascript, I would be ok with that too.

I can't use a flow or a powerapps component for this as I'm creating this for CRM 2011.

I have the same question (0)
  • Suggested answer
    DAnny3211 Profile Picture
    11,336 on at
    Is it possible to reference nodejs in a javascript web resource

    Hi,

     

    Short answer: no—a JavaScript web resource in CRM 2011 runs in the browser, not in a Node.js runtime. The Node‑style require() and most npm modules won’t work directly. You have a few workable options, though:

     
     

    What you can do

     

    1) Bundle modules for the browser (recommended)

     

    • Use a bundler like Browserify or Webpack on your dev machine to compile your modules into one ES5 file that runs in IE8/IE9 (CRM 2011 era).

    • Avoid Node‑only APIs (fs, net, tls, etc.). Pick browser‑friendly packages.

    • Typical flow (example with Browserify + Babel):
      npm init -y
      npm install --save browserify @babel/core @babel/cli @babel/preset-env
      npx babel src/main.js --out-file build/main.es5.js --presets=@babel/preset-env
      npx browserify build/main.es5.js -o build/bundle.js
      

      Upload build/bundle.js as a Script (JScript) web resource and reference it in your form libraries.


    •  
     

    2) Use an AMD loader (RequireJS) inside CRM 2011

     

    • Upload require.js as a web resource, include it first, then load your modules using AMD:
      // /WebResources/new_require
      require.config({
        baseUrl: '/WebResources',
        paths: {
          mylib: 'new_mylib' // points to /WebResources/new_mylib.js
        }
      });
      
      require(['mylib'], function (mylib) {
        mylib.run();
      });
      

      And define new_mylib.js as:
      define([], function () {
        function run() {
          // your logic
        }
        return { run: run };
      });
      

    • Ensure the forms include these web resources and that the load order is correct. Publish all customizations.


    •  
     

    3) Stick to classic namespaces (IIFE pattern)

     

    • For simple scenarios, create one or more global namespaces with IIFEs and load scripts in the desired order via form libraries:
      // new_lib.js
      var MyOrg = MyOrg || {};
      MyOrg.Lib = (function () {
        function doWork() { /* ... */ }
        return { doWork: doWork };
      }());
      

      Then call MyOrg.Lib.doWork() from your event handlers.


    •  
     
     

    Things to watch for in CRM 2011

     

    • ES modules (import/export) are not supported by the legacy browsers; transpile to ES5 and bundle.

    • Polyfills may be needed (e.g., for Promise/fetch). Choose versions compatible with IE8/IE9 or rely on XHR.

    • Keep external libraries as web resources (don’t hot‑link CDNs if the environment restricts internet access).


    •  
     

    If this answers your question or helps you move forward, please mark the reply accordingly so others can find it.

     

    Thanks and best regards,
    Daniele
    Note: This response was prepared with support from Copilot to ensure clarity and completeness.

  • kalluu91 Profile Picture
    40 on at
    Is it possible to reference nodejs in a javascript web resource
    It will work fine as long as it is javascript.
     
    You can write the code in typescript, then compile and build it into javascript.
     
    See this blog post for details how to setup typescript for web resources:
     
    Regards,
    Kim Anh
  • MZ_980 Profile Picture
    101 on at
    RE: Is it possible to reference nodejs in a javascript web resource

    Thanks for sending this.  Regarding the first link, part 3 and part 4 aren't written.  The second link is a tutorial on how to use type script, but it doesn't have any information about loading a module into a javascript web resource.

  • Community Member Profile Picture
    on at
    RE: Is it possible to reference nodejs in a javascript web resource

    Hi MZ_980,

    Maybe you can  refer the following link:

    Modern Web Resource Workspace in Dynamics 365 – Part 1: TypeScript – Dynamics CRM Experience (dyncrmexp.com)

    Dynamics 365 TypeScript Web Resource Tutorial | Dynamics Chronicles (dynamics-chronicles.com)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
DAnny3211 Profile Picture

DAnny3211 206

#2
Sahan Hasitha Profile Picture

Sahan Hasitha 152

#3
Abhilash Warrier Profile Picture

Abhilash Warrier 129 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans