如何从asp.net vnext项目中的wwwroot访问node_modules文件夹 [英] How to access node_modules folder from wwwroot in asp.net vnext project

查看:44
本文介绍了如何从asp.net vnext项目中的wwwroot访问node_modules文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何从放置index.html的wwwroot访问Visual Studio解决方案文件中未包含的node_modules文件夹.该index.html文件需要引用npm已安装的软件包,例如angular.js.

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 reference the npm installed packages like angular.js.

但是如何?

我不想将整个node_modules文件夹复制到wwwroot.这些不是要存放在那里的文件...

I do not want to copy the whole node_modules folder into wwwroot. Those are not the files to live there...

我不想在解决方案中包含node_modules文件夹,因为这会减慢一切并挂断电话...

I do not want to include the node_modules folder to the solution because that will slow down everything and hang up...

似乎前端开发不属于VS ...

It seems Frontend development belongs not in VS...

推荐答案

您不应从wwwroot外部访问文件. wwwroot文件夹是承载主机时可以从外部访问的公用文件夹.

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.

典型的发布过程是,您有一个gulp或grunt任务在ASP.NET Web项目被编译或发布时运行,它将在此处运行任务并复制wwwroot文件夹内的必要文件,即wwwroot/libswwwdata/js.

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.

尽管它没有显示在解决方案中(只是间接地显示在Dependencies/npm部分中),您仍然可以通过单击解决方案资源管理器顶部的显示所有文件"按钮并复制所需文件来使其可见.

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.

这篇关于如何从asp.net vnext项目中的wwwroot访问node_modules文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆