cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community email notifications are disrupted. While we are working to resolve, please check on your favorite boards regularly to keep up with your conversations and new topics.

require is not defined

mewees
2-Guest

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.

4 REPLIES 4

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

mnarang
17-Peridot
(To:mewees)

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

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

jamesm1
5-Regular Member
(To:mewees)

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.

Top Tags