How do I serve static files through Node.js locally?

前端 未结 3 972
你的背包
你的背包 2020-12-31 08:40

I have the following file locations :

file:///Users/MyName/Developer/sitename/scripts (contains all .js files..)
file:///Users/MyName/Developer/sitename/css          


        
3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-31 09:20

    The easiest solution I found on serving local static files is to use Http-Server.

    Its usage is dead simple. After installing it globally

     npm install http-server -g
    

    Go to the root directory you want to serve

    cd 
    http-server
    

    That's it!

提交回复
热议问题