Friday, 19 April 2019

ReferenceError: rivescript is not defined; I can't refer npm package when initializing it in script.js file, does anyone know how to solve this, much thanks in advance

I recently updated a chatbot I had originally coded using Jquery and rivescript. Now I want to store user input in a database whenever the bot doesn't understand the user so I'm using node, with the dependencies: express, mysql, rivescript, body-parser. And I changed my code to an mvc pattern.Before I had linked rivescript thru a cdn on the index.html file, and initialized it in the jquery file as: Let bot = new RiveScript();bot.loadFile("brain.rive").then(brainReady).catch(brainError);Now, I installed rivescript as a npm package, problem is I can't require("rivescript") in my public/assets/js/script.js, cuz that's only for the node side of the app.But when I run the code on my browser the page returns the error in the title. How can I reference and Initialize the rivescript pack so I can access it from my script.js file?Should I move all my rivescript logic to the app.js file that starts the server?I'm sure this is really dumb, but I can't seem to figure it out. Thanks for your time, I can give more details about it

Submitted April 20, 2019 at 02:19AM by habaresbit

No comments:

Post a Comment