0

What is the ideal way to link to assets in the node_modules folder to be deployed to Heroku?

I am using NodeJS using EJS Javascript templating. My app has dependencies on jQuery and Bootstrap. I used NPM to pull those modules into node_modules and then tried to link them in my html as follows:

 <!-- Bootstrap CSS and custom CSS links -->
 <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" media="screen" charset="utf-8">
 <script src="node_modules/jquery/dist/jquery.min.js" charset="utf-8"></script>
 <script src="node_modules/bootstrap/dist/js/bootstrap.min.js" charset="utf-8"></script>

 .
 ├── Procfile
 ├── README.md
 ├── app.js
 ├── app.json
 ├── node_modules

 │   ├── bootstrap
 │   │   ├── dist
 │   │   │   ├── css
 │   │   │   └── js

 │   │   ├── jquery
 │   │   │   ├── dist
 │   │   │   │   ├── jquery.min.js

 ├── package.json
 ├── public
 │   ├── css
 │   ├── img
 │   └── js
 └── views
     ├── pages
     └── partials

This did not work. Apologies and thanks in advance for your help with such a noob question.

emveeoh
  • 86
  • 6

1 Answers1

0

I found a suitable answer in this related question: https://stackoverflow.com/a/27464258/6111872

Specifically, this syntax:

 app.use('/scripts', express.static(__dirname + '/node_modules/bootstrap/dist/'));
Community
  • 1
  • 1
emveeoh
  • 86
  • 6