Reputation: 14404
I'm trying to figure out of if there is a feature or convention I'm missing for referencing a js file from a node_module in the client html via script
. For example, I have underscore
installed via npm and use it on the server side, but also want to use underscore-min.js
in the client. Right now i symlink the file into my expressjs static folder, but that seem hacky.
Is there an official or at least cleaner way?
Upvotes: 3
Views: 531
Reputation: 1511
underscore-min.js
really has nothing to do with node. It's a distributed file for serving to clients. My advice is to copy it out of the module into any static serving location you want. It may feel hacky to have 2 copies of the same file, but it's not. You may even want them to be updated separately.
Upvotes: 0
Reputation: 63653
You can try browserify and put all your js files (Node modules) in a folder, for more details checkout his awesome article:
http://substack.net/posts/24ab8c/browserify-browser-side-require-for-your-node-js
Upvotes: 4