'How to use jQuery after downloading it using NuGet
I downloaded jQuery
in Visual Studio 2017
using Install-Package bootstrap -Version 4.1.1
Now I have a dependency which includes jQuery 3.3.1, but when I move to my script file, I can´t access jQuery
and I don't get IntelliSense
for jQuery
when I enter $.
Is there some reference I must enter, in order to use jQuery
in my script file?
Solution 1:[1]
How to use jQuery after downloading it using NuGet
You should use Bower
or the npm
(Node Package Manager) to add the JavaScript libraries instead of using NuGet. Because the usage of NuGet for css/javascript
libraries is discouraged.
However, since ASP.NET Core 2.0 and the End of Bower, so we recommend you to use npm
(Node Package Manager) to manage css/javascript
libraries.
To use the package bootstrap
to the .net core project, you need to select your project and add a new file to the project root. While in the template manager (Add->New Item...), search for "npm Configuration file".
Then edit the file and add your dependency, i.e.
package.json (npm):
"devDependencies": {
"bootstrap": "4.1.1"
}
Note: For package.json (npm), once you save, the file will be downloaded in a directory named "node_modules`. This alone won't be enough, as the required files need to be copied over to wwwroot folder, where they can be accessed when the application runs.
For the detailed info, see NPM, BOWER, NUGET, GULP – The Four Horsemen of ASP.NET CORE Apps.
Solution 2:[2]
Apparently, you should switch package managers for client-side scripts, to npm or bower!
See jQuery and Fullcalendar.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Andy Joiner |
Solution 2 | Phume |