Is it possible to load node.js module in dojo framework used for building custom widget? Any sample code is greatly appreciated.
Same problem here. I've tried to load SheetJS, ExcelJS, file-saver.js, and so many others, just for a simple use case of trying to export my excel document to the user.
There's ZERO documentation from Dojo on how to utilitize your node modules that you install in your widget (im using js api 3.x)
I have the same problem to load "dojo/node!fs". I got an error message with "cannot find node.js require" . does anyone has a solution to this issue? Thanks!
I ended up using .net Web api rest services in my web app builder widgets.
The widget cannot load "dojo/node!fs" for me, even if i define('dojo/require'). I'm working in WAB environment. Could you give me a workaround?
Thank you!
Hi Sapna,
I am trying to implement the same but no luck. Did you find any other way around?
I am also trying to store custom widget's run time settings into custom_config.json.
Any help would be appreciated.
Regards,
Prashant
how do you incorporate the logic in widget.js?
define
([
...
'dojo/node!fs'],
function(.....,fs)
{
somefunction:function(){
fs.readFile("MyFile.json", function (err, data) {
if (err) alert("error");
});
}
I understand it is a client side script but the apps are stored in server folder once created through webappbuilder. I just need a way to manipulate the apps during runtime. I'm currently using a mixed bag with service to manipulate app on iis while the client apps on nodejs.
Can you be more specific. Also which version of JS Api are you using?
If it is about just requiring nodejs module in AMD. you can do it like below.
<SPAN class="comment token">// This:</SPAN> <SPAN class="keyword token">var</SPAN> fs <SPAN class="operator token">=</SPAN> <SPAN class="token function">require</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"fs"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// Would become:</SPAN> <SPAN class="token function">require</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN> <SPAN class="string token">"dojo/node!fs"</SPAN> <SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">function</SPAN><SPAN class="punctuation token">(</SPAN>fs<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">{</SPAN> <SPAN class="comment token">// Utilise the "fs" module</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Complete details can be found here Dojo and Node.js - Dojo Toolkit Tutorial
Hope this was helpful.
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.