0

Can anyone point me to instructions on how to use an npm package in an asp.net core application using Visual Studio 2019? Specifically, I am using the DOMPurify npm package (https://www.npmjs.com/package/dompurify)

I am new to npm and feeling my way. I have npm installed on my machine. I added a package.json to the project, and in there I added this bit of code:

"devDependencies": {
"dompurify": "2.2.6"

}

When I hover over this with my cursor I see the DOMPurifiy intellisense information, and a folder named "npm" was added to my Dependencies node, and in there I see "dompurify (2.2.6)", so something happened, but no files get downloaded. I was expecting something like adding a Nuget package, where the files get downloaded, but that does not occur.

I simply downloaded the javascript file I need from the github site and added that to my project, and it works fine. What is the purpose of the package.json and the "npm" dependencies node? Is there any way to manage these packages in Visual Studio, similar to how Nuget works?

Tom Regan
  • 3,580
  • 4
  • 42
  • 71
  • why not just use ``? – sagar1025 Dec 19 '20 at 02:07
  • @sagar1025 I fixed my issue with referencing the file, it works just as you describe, and I edited my question accordingly. But that was a red herring. My real question is, is there any way in Visual Studio to maintain npm packages, similar to how Nuget packages can be maintained using the Nuget package manager? – Tom Regan Dec 19 '20 at 13:57
  • This should help you understand npm and its integration with VS https://stackoverflow.com/questions/37935524/how-to-use-npm-with-asp-net-core As far as dependencies goes this is the official documentation from nodejs. https://nodejs.dev/learn/npm-dependencies-and-devdependencies I hope this helps – sagar1025 Dec 19 '20 at 21:02

0 Answers0