Bootstrap 3.3.6 JQuery 2.2.4 Version Exception

前端 未结 3 1930
野的像风
野的像风 2020-12-03 12:15

I am trying to use Bootstrap and JQuery in my new ASP.Net Core application. But I encounter the error \"Bootstrap\'s JavaScript requires jQuery version 1.9.1 or higher, but

相关标签:
3条回答
  • 2020-12-03 12:36

    We found that the root of the problem is git.exe from C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External\git which is not a real Git but some sort of a wrapper.

    With it, bower tries to install correct versions, but if you look into the bower cache you can see that actual downloaded files don't match.

    Example:

    C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External>
    
    bower install jquery#2.2.4
    bower jquery#2.2.4          not-cached https://github.com/jquery/jquery-dist.git#2.2.4
    bower jquery#2.2.4             resolve https://github.com/jquery/jquery-dist.git#2.2.4
    bower jquery#2.2.4            checkout 2.2.4
    bower jquery#2.2.4            resolved https://github.com/jquery/jquery-dist.git#2.2.4
    bower jquery#2.2.4             install jquery#2.2.4
    
    jquery#2.2.4 bower_components\jquery
    

    Check the contents of "%USERPROFILE%\AppData\Local\bower\cache\packages\35300e45e44dbc6f186ed069533ef0af\2.2.4\dist\jquery.js":

    /*eslint-disable no-unused-vars*/
    /*!
     * jQuery JavaScript Library v3.1.0
    

    Solution:

    1. Install Git for Windows
    2. Delete %USERPROFILE%\AppData\Local\bower
    3. Restart Visual Studio
    4. Delete wwwroot/lib and Restore bower packages

    Update: You might also need to adjust VS external web tools settings

    0 讨论(0)
  • 2020-12-03 12:49

    Delete the Lib forder on the wwwroot and run bower install, ensure that in your bower.json file you have the version of jquery that you want.

    0 讨论(0)
  • 2020-12-03 12:52

    As pointed out by Phil, this is caused by Visual Studio's built in Bower support. When using this, it seems to download a different version of JQuery.

    To fix this, I just used the proper Bower client and installed my packages through the console.

    0 讨论(0)
提交回复
热议问题