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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

require is not defined

mewees
2-Explorer

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

mewees
2-Explorer
(To:mnarang)

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
12-Amethyst
(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.

Announcements


Top Tags