Wednesday 17 May 2017

How to include npm packages in ASP.NET MVC project?

I'm a total novice to npm, or really any package managers.

I'm working on a ASP MVC project within Visual Studio, and I have npm and bower installed globally on my computer. I'm trying to use the bootstrap-material-design package in my project. I manually created a package.json file using Visual Studio.

I opened a CLI at the project root and ran npm install -S bootstrap-material-design. That created a folder node_modules at project root, with bootstrap-material-design inside. I've included these folders in my project. It also changed my package.json file. Now, it looks like this: { "version": "1.0.0", "name": "asp.net", "private": true, "devDependencies": {}, "dependencies": { "bootstrap-material-design": "^0.5.10" } } It appears to me that the package is "included" in my project. But my question is: how do I use it? All the npm guides I've been reading seem to suggest I can just start using the package in my javascript code and Visual Studio will somehow know that I'm trying to use to the package. But bootstrap-material-design has CSS files and JS files it needs included on every page. Where do those folders get included? In _Layout.cshtml? I'm pretty stuck.

Thank you!



via Harry T

No comments:

Post a Comment