4 Replies Latest reply on Oct 7, 2017 2:30 AM by jamesm RSS
    mewees Newbie

    require is not defined

    Hello There,

     

         i'm trying to write a javascript code inside thingworx from Services tab.

    but when i tested the script it gave me this error 'require is not defined'

    is there any solution for this issue.

     

    Br,

    Mohamed Ewees.

      • Re: require is not defined
        stevegr Apprentice

        Can you paste the javascript - difficult to under the error message without

        • Re: require is not defined
          mnarang Explorer

          I think somehow you are using require() function in your code ,that's why you are getting some reference error .By default require() is not a valid function in client side JS. you need to extend the JS to have the function require() by looking into require.js .

           

          I think i am taking this into right direction ,as you only mentioned the error ,full JS code will be more helpful to check this out .

           

           

           

          Thanks

          Mukul Narang

            • Re: require is not defined
              mewees Newbie

              Hi Mukul,

               

                   thanks a lot for your response.

              i'm trying to do something like "var http = require("https"); " but  it gave me this error 'require is not defined'.

              so , how can i extend the JS to have the function require() by looking into require.js

                • Re: require is not defined
                  jamesm Creator

                  Thingworx Services are not able to import libraries like in node.js. If you are trying to call a REST or SOAP service, check out the snippets for ContentLoaderFunctions, this will let you do things like GET/POST/PUT requests.