如何将通过NPM安装的库包含到Visual Studio 2017上的MVC项目中 [英] How do I include libraries that installed via NPM to my MVC project on Visual Studio 2017

查看:168
本文介绍了如何将通过NPM安装的库包含到Visual Studio 2017上的MVC项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图从鲍尔移到 NPM .

当我使用 Bower 时,很容易配置 .bowerrc 文件,并将下载的库保存在诸如 wwwroot/lib 的目录中strong>

While I was using Bower, it was easy to configure the .bowerrc file and have the downloaded libraries in a directory such as wwwroot/lib

现在,我正在开发ASP.Net Core MVC应用程序,并尝试使用 NPM 作为我的默认程序包管理器.通过在Visual Studio 2017中使用命令行, NPM 创建 package.json 文件并将库下载到node_modules文件夹中.那接下来是什么?如何获得 wwwroot/lib Director中曾经拥有的JS或CSS文件?

Now, I am developing a ASP.Net Core MVC app and trying to use NPM as my default package manager. By using Command Line in Visual Studio 2017, NPM creates package.json file and download libraries to node_modules folder. Then, what is next? How can I get JS or CSS files like I used to have in wwwroot/lib director?

推荐答案

好的,这就是问题了.

Ok, so heres' the thing.

NPM:Node JS软件包管理器,可帮助您管理软件所依赖的所有库.您可以在一个名为package.json的文件中定义您的需求,然后在命令行中运行npm install ... ANG,您的软件包已下载并可以使用.可以同时用于前端和后端.

NPM: Node JS package manager, helps you to manage all the libraries your software relays on. You would define your needs in a file called package.json and run npm install in the command line... BANG your packages are downloaded and are ready to use. Could be used both for front-end and back-end.

资源: https://www.quora.com/What-are-the-differences-between-NPM-Bower-Grunt-Gulp-Webpack-Browserify-Slush-Yeoman-and-Express

现在,这是NPM停下的地方,他的亲爱的朋友Gulp接管了.我无法全部输入,但是要将您的css和js文件放在一个文件夹中(以及对它们进行任何操作),您将不得不使用自动化工具(我个人使用Gulp,但其中有很多在那里.)

Now, here's where NPM stops and his dear friend Gulp takes over. I can't type all of it, but to have your css and js files in a folder (and do whatever you want with them) you'll have to use an automation tool (I personally use Gulp but there's a bunch of them out there).

设置简单,文档在这里: https://gulpjs.com/

It's easy to set up and the documentation is here: https://gulpjs.com/

Gulp基本上将负责css文件的编译方式和位置.它将其对软件包的请求建立在node_modules文件夹中.所以你很好.配置gulp,您就该走了.

Gulp will basically be responsible of how and where your css files get compiled. It will base its requests for packages in the node_modules folder. So you're good to go. Configure gulp and you should be on your way.

还有webpack.从未使用过它,但这似乎是自动化的未来:

There's also webpack. Never used it, but it seems to be the future of automation:

https://webpack.js.org/

我建议使用webpack.

I'd suggest using webpack.

这篇关于如何将通过NPM安装的库包含到Visual Studio 2017上的MVC项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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