Trying to use Underscore JS in a Node.JS project. Really stumped why it is not working. Note: This works if I simply use the CDN for underscore. However I'd really like to know why I am unable to get this to work using NPM.
I am getting this error:
Uncaught ReferenceError: _ is not defined
Installed with: npm install underscore --save
Within the app.js file & Index files have tried both of these:
var _ = require('underscore')._
and
var underscore = require('underscore');
Even tried requiring it within the page render:
res.render("dashboard", {currentUser: req.user, underscore : underscore});
This is the test I'm using:
<script>
var tacos = ['beef', 'chicken', 'soft', 'hard', 'With nacho cheese']
_.shuffle([tacos]);
console.log(_.shuffle(tacos));
</script>