How to access node_modules folder from wwwroot in asp.net vnext project

后端 未结 2 1437
Happy的楠姐
Happy的楠姐 2020-12-11 01:36

How can I access the node_modules folder which is not included in the visual studio solution file from the wwwroot where my index.html is put. That index.html file need to r

2条回答
  •  执笔经年
    2020-12-11 02:14

    You are not supposed to access files from outside of wwwroot. The wwwroot folder is the public folder that's accessible from outside, when you host it.

    Everything over it, is off-limits.

    The typical publishing process is, that you have a gulp or grunt task that runs when your ASP.NET webproject is compiled or published, it would run the tasks there and copy over the necessary files inside wwwroot folder, i.e. wwwroot/libs or wwwdata/js.

    Of course you can also manually copy the files over, but that's rather bad especially when you update many dependencies it's hard to keep track manually.

    While it's not displayed in the solution (just indirectly, in the Dependencies/npm section), you can still make it visible by hitting the "Show all files" button on top of the Solution Explorer and copy over the files you need.

    But it's best to set up a gulp task for it, but that's out of the scope of this question.

提交回复
热议问题