5

I want to link to /node_modules/jade/runtime.min.js client-side -- how do I make it publicly accessible?

Do I create a app.get for it somehow?

app.get('/js/jade-runtime.js',<what goes here?>)

Or can I modify the static thing to allow it to be served?

app.use(express.static(path.join(__dirname, 'public'))); // modify this to add more paths somehow

Full solution (thanks Brad):

app.get('/js/jade-runtime.js',function(req,res) {
    res.sendfile(path.join(__dirname,'node_modules','jade','runtime.min.js'));
});

1 Answer 1

5

You can use this with your app.get.

res.sendfile('jade-runtime.js');

Obviously, use the correct path to where that file is located.

http://expressjs.com/api.html#res.sendfile

Sign up to request clarification or add additional context in comments.

2 Comments

Awesome! Works perfectly, thank you! I thought there might be a function like that but I wasn't sure what to look for.
@Mark, Great! I'm happy it works for you. Yes, the Express documentation is a bit difficult to use. I just started working with it myself earlier this weekend. I think once I fully understand what all there is to it, I might try to contribute to fixing the docs. It seems documentation isn't a priority for any of the Node.js-based stuff out there, presumably because the projects are so new and rapidly changing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.