Magneto10 Magneto10 - 2 years ago 98
Node.js Question

Cannot include jQuery and Bootstrap

I installed jQuery and Bootstrap with Bower.

I got this error

syntaxerror: expected expression, got '<' <!doctype html> jquery

My code

<script src="../bower_components/jquery/dist/jquery.min.js"></script>
<script src="../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>

There is my folder structure

I also tried to put the code in head, but did not work

Here is my server data

var express = require('express'),
app = express();

.get('*', function (req, res) {

Answer Source

I use this on server.js:

app.use('/bower_components',  express.static(__dirname + '/bower_components'));  

now in anything place I can use this and work fine, example:

<script type="text/javascript" src="/bower_components/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>

with this you call directly to the folder

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download