- bootstrap
- jquery
- jquery-validation
- jquery-validation-unobtrusive
如果Bower已被弃用,请不要将此问题复制到在Visual Studio 2017中如何使用Bower包中!我不希望修复指向弃用技术的解决方案。
我想缩小问题范围:最简单(最直观)的用NPM替换Bower的方法是什么?就像Bower使用它的
.bowerrc
文件一样: { "directory": "wwwroot/lib" }
?.bowerrc
文件一样: { "directory": "wwwroot/lib" }
?微软推出了一个轻量级并且目前还比较低调的解决方案,叫做 Library Manager (LibMan)。
它是一个基于 JSON 的简化解决方案,并且拥有非常简单易用的用户界面——能够让您控制下载哪些文件(不再需要下载数百个文件,当您只需要其中的一个时)。
Mads Kristensen 在 Build 2017 演示了一个非常棒的预览版。 (该视频应该会在大约 43 分钟 34 秒处开始。)
撰写此文时,LibMan 仍处于预览状态,但将随 Visual Studio 15.8 一起发布。
如果您想在此之前尝试它,可以从GitHub Repo或Visual Studio Marketplace获取它——在解决此问题的方案中有说明。
您仍然可以使用npm等工具-不过这里是微软使用此工具(或同时使用)的原因——来自Visual Studio Marketplace:
使用此扩展的原因
- 针对目前未使用其他包管理器的应用程序
- 针对您认为Bower和npm过于繁琐的项目
- 针对不想使用Bower或npm的开发人员
- 针对在其工具中重视简洁的开发人员
- 用于自定义或私有的包/文件
- 用于NuGet无法安装内容包的ASP.NET Core应用程序
Bower已经停止维护。Bower团队建议使用Yarn(NPM的一个补充)。
由于Visual Studio支持NPM
,所以我会选择它。
在你的项目根目录下创建一个package.json
文件(右键点击项目,添加项并搜索NPM
,你会找到一个npm配置文件
):
{
"name": "SomeName",
"version": "1.0.0",
"private": true,
"dependencies": {
"bootstrap": "3.3.7",
"jquery": "3.3.1",
"jquery-validation": "1.17.0",
"jquery-validation-unobtrusive": "3.2.10",
"jquery-ajax-unobtrusive": "3.2.4",
}
}
node_modules
文件夹中。这是新的包管理器。bundle.js
,bundle.css
,sprite.svg
的过程。这些应该复制到wwwroot
文件夹中。https://github.com/madskristensen/BundlerMinifier
https://marketplace.visualstudio.com/items?itemName=MadsKristensen.PackageInstaller
npm install bootstrap --save
甚至不能安装bootstrap的依赖项。这是包管理器的一个不可接受的失败。在我看来,Library Manager似乎是正确的解决方案。 - user875234Tools - Extensions and Updates
from the main menuOnline
on the left menu and type package
in the Search box. Download the Package Installer
Project - Quick Install Package
from the menunpm
and type upgrade -g bower
in the fieldbower.json
file manually as follows:
bower.json
{"name": "myproject"}
.bowerrc
.bowerrc
file and type the following: {
"directory": "wwwroot / lib /",
"registry": "https://registry.bower.io"
}
bower.json
file and select the Manage Bower Package
option.mustache.js
and install那就是全部!
以下博客对我有用,尽管它声称问题将在15.8中得到解决,但与此问题相反:
https://blogs.msdn.microsoft.com/webdev/2018/07/05/workaround-for-bower-version-deprecation/
我已经更新了.bowerrc文件,包括:
"registry": "https://registry.bower.io"
然后右键单击bower.json并还原软件包。 然后,瞧!