blue-sky blue-sky - 6 months ago 30
Node.js Question

How to use a node.js library in html?

I install fancybox dependency via :

npm install fancybox

I'm attempting to use the fancybox css within a html page :

<a class="fancybox fancybox.iframe"

I cannot
the fancybox library within the html page ?

Prior to using node I would just import the library directly on the page:

<script src=""></script>
<link rel="stylesheet" type="text/css" href=""></link>

But how to use the node library on html page ?

Update :

To achieve this I just copied the node_modules directory to the public folder. Then exposed the library with :

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

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


The way to do this is to use a build tool such as webpack. You use npm to install your libraries into the node_modules/ subdirectory, require them within your javascript files and use webpack to produce a single bundle .js file that contains everything.

I'd start here: