I've just created a new ASP.NET Core 1.0 app targeting .NET Framework 4.6.1 and installed a few NuGet packages but I'm not seeing a package.json file in the root of my project.
Is the new ASP.NET Core 1.0 project not using package.json? If so, where do we save package information?
So, possibly there is a confusion here between Nuget packages and npm packages? Nuget packages are typically providing .net assemblies for use on the server, where as npm packages are providing either client-side javascript libraries (bootstrap, react etc.) and/or server-side node features (e.g. express).
Typically in a dot net core project you aren't using a node server (you're using a dot net one), so instead of using npm for package management which then returns both client and server JS modules, the default templated projects instead use Bower which deals only with client-side modules.
Nuget Packages:
In earlier versions of dot net core Nuget package details were in a project.json
file, but are now back in the .csproj
file again. If you're looking at the solution in full Visual Studio you won't see the .csproj
file because VS likes to be in control of editing the project configuration, so in that case you typically use the Package Manager Console (PMC) or the 'Manage Nuget Packages' menu option to update the details of what Nuget packages your project uses.
Bower for client side Javascript: If you look under the Dependencies folder in Solution Explorer in VS you'll find the Bower folder. If you right click on that and choose Manage Bower Packages you'll see the Bower Package Manager (or you can just edit the Bower.json file in the project folder, although, again, you won't see this in the Solution Explorer in VS):
NPM: If you want npm instead/too, then just manually create a package.json
file in the project and after building the project you'll find a node_modules folder has been added to your solution and that there's now a npm folder in solution explorer under the Dependencies heading:
If you right click on the npm folder icon there is then a Restore Packages option, but that didn't actually work for me when I clicked it and if it did I'm not sure if that is then automatically included in the build process, or if further wiring up is needed.
If you want an example of a asp net core project that uses npm instead of bower, then you could try one of the excellent SPA templates generated by Microsoft's JavaScriptServices tools.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With