I use http-server from npm, the file structure is as follows:

  • http-server
  • node_modules
  • public

    • index.html; js; css

src = "/ node_modules / angular / angular.js" connect angular

Does not find it, what to do?

    1 answer 1

    From the instructions :

    Using:

    http-server [path] [options] 

    [path] defaults to ./public if this folder exists, otherwise ./ .

    The server gives the public folder, it is the root of the site. And node_modules are not in it.

    What to do, a lot of options.

    A good option is to collect one hefty JSin with all dependencies somewhere in the public with the help of some bandler, of which there are many. Immediately call Webpack and Browserify .

    You can also install AngularJS differently, through Bower, by telling it to place the modules in public following content in .bowerrc in the project folder :

     { "directory" : "public/components" } 

    You can also configure the web server to send files to different addresses from different folders. But this is already if you do not use the http-server .


    A quick and dirty move is to make a symlink (a symbolic link ) in public to the location of the angular. I will not specifically bring the ready-made team, because it is a dangerous trick, which is worth using only if you understand exactly what you are doing.