2

As far as references to directories are concerned, I understand

./ = current
../ = parent

But I am having a problem referencing my bower_components directory in this bit of HTML code. The reference to the lib folder works fine but not bower_components. What am I missing?

main.html

<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>
        <script src="lib/jquery/dist/jquery.min.js"></script>
        <script src="../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
    </body>
</html>

Directory structure looks like this: enter image description here

Community
  • 1
  • 1
emi
  • 2,830
  • 5
  • 31
  • 53
  • 4
    What's in `server.js`? My guess is that it's implementing more-o-less boilerplate middleware for serving static files (CSS, client-side js etc.) from its `public` directory, but not from `bower_components` one. As for path part, `../bower_components/foo/bar` is quite fine. – raina77ow Sep 25 '15 at 11:37
  • Check (most probably) [related question](http://stackoverflow.com/questions/21821773/configure-node-express-to-serve-static-bower-components). – raina77ow Sep 25 '15 at 11:39
  • got it. thank you @raina77ow – emi Sep 25 '15 at 11:54

2 Answers2

1

Try going to <your server>/bower_components/bootstrap/dist/js/bootstrap.min.js

It probably won't work. If your server setup is normal only public and the folders below it are accessible from the client side. From the client point of view public is the root, there is nothing above that.

As for importing bootstrap, see if you can browse what node is making available in your browser. It's probably hosting the scripts you need to reference on the client side at another url. You might also find the url in the bower documentation/examples.

You could solve this by copying or symlinking the scripts into the public directory, but that would be a bit hackish, save it for if you get completly fed up with finding the intended way.

Faxn
  • 366
  • 2
  • 3
0

Maybe you can try this

<script src="contacts/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>

just use the full script path

Xu Lei
  • 5
  • 3