Search code examples
modulewakandassjs

wakanda can't load ssjs modules


I have been trying to use the sample server side mail module, as referenced here. In the sample code the line that loads the module

var mail = require('waf-mail/mail');

produces the following error

desktop.core.min.js:formatted:5206 Uncaught Can't find module "waf-mail/mail".o @ desktop.core.min.js:formatted:5206button1_click @ index.js:13(anonymous function) @ desktop.core.min.js:formatted:5875i @ desktop.core.min.js:formatted:5861r.fire @ desktop.core.min.js:formatted:5873o @ desktop.core.min.js:formatted:5908l.domCallback @ desktop.core.min.js:formatted:5968dispatch @ desktop.core.min.js:formatted:1804a @ desktop.core.min.js:formatted:1636

This occurs in an existing solution/project & in a newly created one, I have tried other SS modules with the same result. The module directory & modules are present inside the (OSX) server package. Am I misunderstanding something fundamental here?


Solution

  • Looks like, you're using a Server-side module in a Client-side script.

    desktop.core.min.js is a frontend file that cannot find the required waf-mail/mail module not defined here.

    If you want to send a mail, you can add a requestHandler to your bootstrap and call for the SSJS script that will send your mail.

    http://doc.wakanda.org/home2.en.html#/HTTP-Request-Handlers/Introduction-to-HTTP-Request-Handlers.200-803294.en.html