I'm stuck trying to add Bootstrap to my index.js file as per instructions on Bootstrap's site. Their suggestion errors out when I try it. I'm pretty sure there's something I'm missing, but I don't know what.
index.js is:
const express = require('express');
const hbs = require('hbs');
import 'bootstrap';
const app = express();
hbs.registerPartials(__dirname + '/views/partials');
app.set('view engine', 'hbs');
app.get('/', (req, res) => res.render('index'));
app.listen(3000, () => {
console.log('App listening at port 3000!')
});
Error out is:
import 'bootstrap';
^^^^^^
SyntaxError: Unexpected token import
My package.json is:
"dependencies": {
"bootstrap": "^4.0.0",
"express": "^4.16.2",
"hbs": "^4.0.1",
"jquery": "^3.3.1",
"popper.js": "^1.12.9"
},
Hmm! When I added the following to the head of my index.hbs file it seems that bootstrap works for rendering the navbar properly now, but I'd like to achieve the same by using bootstrap installed through node npm.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">