Bower在VS2015.3下载错误版本

时间:2016-07-08 08:04:14

标签: jquery visual-studio-2015 asp.net-core bower

我在asp内核心1.0项目中遇到了凉亭内的问题。我的bower.json就是这个

{
  "name": "asp.net",
  "private": true,
  "dependencies": {
    "bootstrap": "3.3.6",
    "jquery": "2.2.4",
    "jquery-validation": "1.14.0",
    "jquery-validation-unobtrusive": "3.2.6"
  }
}

但是当我去凉亭下载的libs时我发现jquery是v3.1.0

/*eslint-disable no-unused-vars*/
/*!
 * jQuery JavaScript Library v3.1.0
 * https://jquery.com/
 *
 * Includes Sizzle.js
 * https://sizzlejs.com/
 *
 * Copyright jQuery Foundation and other contributors
 * Released under the MIT license
 * https://jquery.org/license
 *
 * Date: 2016-07-07T21:44Z
 */

我以为这是我的机器,但它发生在三台不同的机器上。我做错了吗?

修改 我试过这个:

{
  "name": "asp.net",
  "private": true,
  "dependencies": {
    "jquery": "~2.2.4"
  },
  "resolutions": {
    "jquery":  "<=2.2.4"
  }
}

bower.json中配置的唯一包是jquery,仍然安装jquery 3.0.1。为什么凉亭这样做? npm / bower的输出窗口说:

  

PATH =。\ node_modules.bin; C:\ Program Files(x86)\ Microsoft Visual Studio 14.0 \ Web \ External;%PATH%; C:\ Program Files(x86)\ Microsoft Visual Studio 14.0 \ Web \ External \混帐   “C:\ Program Files(x86)\ Microsoft Visual Studio 14.0 \ Web \ External \ Bower.cmd”install --force-latest

     

bower jquery#~2.2.4 cached https://github.com/jquery/jquery-dist.git#2.2.4

     

bower jquery#~2.2.4验证2.2.4对https://github.com/jquery/jquery-dist.git#~2.2.4

     

bower jquery extra-resolution不必要的解决方案:jquery#&lt; = 2.2.4

     

bower jquery#~2.2.4安装jquery#2.2.4

     

jquery#2.2.4 wwwroot \ bower \ jquery

6 个答案:

答案 0 :(得分:6)

This is a known issue in the tooling repo:

https://github.com/aspnet/Tooling/issues/575

I simply switched to npm, which resolves the correct package version just fine.

答案 1 :(得分:6)

我遇到了同样的问题并成功解决了这个问题。随Visual Studio 2015一起提供的bower存在问题,可能是在Visual Studio更新之一中引入的。你能做什么:

  1. 安装Git(依赖)
  2. 安装nodejs
  3. 安装凉亭
  4. 配置Visual Studio选项以使用已安装的nodejs版本
  5. 删除bower缓存文件夹%USERPROFILE%\ AppData \ Local \ bower
  6. 参考: http://josharepoint.com/2016/05/04/how-to-configure-visual-studio-2015-integration-with-latest-version-of-node-js-and-npm/

答案 2 :(得分:2)

另一个时间黑客,直到Microsoft修复此问题可能是bower.cmd的更改内容,以从参数列表中删除--force-latest字符串。

我的Visual Studio 2015.3安装文件bower.cmd位于C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External

你应该替换:

@"%~dp0\node" "%~dp0\node_modules\bower\bin\bower" %*

使用:

ECHO OFF
set params=%*
ECHO %params% | %WINDIR%\system32\FIND "--force-latest" >nul & 
IF ERRORLEVEL 0 (call set params=%%params:--force-latest=%%%)
@"%~dp0\node" "%~dp0\node_modules\bower\bin\bower" %params%

上面的代码将检查参数,如果--force-latest存在,将被删除,然后执行带有清除参数字符串的bower。

答案 3 :(得分:0)

我有同样的问题。修复了删除jquery包,添加然后手动将其添加到bower.json并使用正确的版本: “jquery”:“2.2.4”, 希望这会对某人有所帮助。

答案 4 :(得分:0)

这是一个GIT包装器问题,这个post非常有助于解决此问题: 已安装GIT for windows并更改了Visual Studio外部Web工具 (工具 - >选项 - &gt;项目和解决方案 - >外部Web工具)从“$(VSINSTALLDIR)\ Web \ External \ git”到“C:\ program files \ git \ bin” 清除了临时文件并恢复了凉亭。

现在一切正常。

答案 5 :(得分:0)

我的,有点hackish,解决方案是从bower.json中删除jQuery的显式版本,并让bootstrap自己解决该依赖。

我的bower.json看起来像这样:

{
  "name": "asp.net",
  "private": true,
  "dependencies": {
    "bootstrap": "~3.3.6",
    "font-awesome": "4.7.0"
  }
}