My application is Node.JS, using .ejs to render views.
I'm trying to get require a dependency folder from node_modules, instead of having to place that node_module module(jquery, angular, moment, jquery-ui, kendo-ui-core, etc.) physically inside my 'public' folder for grabbing assets for my application or having to refer to a CDN in a script tag in my .ejs(html)file. I've tried adding:
var moment = require('moment');
in my server.js(or what you would call 'app.js' or 'index.js' file) at the root of my application, but this doesn't seem to grab this folder. I've also tried to place
var moment = require('moment');
within a javascript(.js) file, at the very top and was receiving an error stating: 'require isn't defined'. I'm assuming that NodeJs should know which modules are within its Node_modules folder so I'm thinking that maybe in my server.js file, node_modules isn't set to be used like my public folder is being used.
app.use(express.static(__dirname + '/public'));
using the app.use function. Most tutorials and even docs I've looked through just give the simple instruction: 'Just add var moduleName = require('module');' but they don't really elaborate in which file I do this, or if there is anything else to do to set this up outside of declaring a variable to a require function. I don't use a module loader so this MAY be the reason I'm getting the require is not defined. Also, I'm thinking maybe the installation of these modules either being installed globally(-g) or locally could possibly be a reason. But yea, totally lost.
In Summary: How do I use the node_modules in just one of my javascript files and how would I use this within my .ejs file without moving the js file outside of node_modules?