The npm community forum has been discontinued.
To discuss usage of npm, visit the GitHub Support Community.
Why is npm used for client-side code?
I’ve always used npm for node.js code. But I’m learning ASP.NET Core MVC and they seem to be recommending npm for client-side libraries. Well, you can imagine my surprise. npm in an ASP.NET project for client-side code. Why not!
It depends on how you want to build your clientside GUI.
In this scenario you typically use npm packages to serve as building blocks for your client side code.
This architecture feels like rich-client development with clear separation of concerns. Ones you are used to this way of working you will never go back to server side rendering.
Thanks for the reply. Is npm becoming more ubiquitous across different types of web serverrs? Like ruby and php? When you use npm in a node project do you have a seperate node_modules directory for client-side and a server-side code? In ASP.NET Core MVC they seem to be recommending putting node_modules in the root directory and then using webpack to push/manipulate code into the public directory.
Is npm becoming THE repository for client-side code sort of like steam is THE (main) repository for games?
Because I have a strong Microsoft oriented background my preferred development tool is Visual Studio. Support for building web client applications in Visual Studio is very well supported. Typically I separate Client side code and Server side code completely into separate projects because they are based on completely different technology. So each project will have its own dependencies. The Client side project is based on the Node.js template and server side project base on a template you prefer (WCF, Webapi, .net core or ……Whatever you prefer). Server side you simply need something that can handle http requests and serve json.
If you want to have an example of the client side code have a look at https://github.com/williwyg/jpf
This is a small library I am working on at the moment. This might give you an idee howto structure your client side code.
Thanks for the reply. Good luck with your project. At the moment I only need npm for the client-side since I’m learning about all this while learning ASP.NET Core MVC so client/server structure doesn’t matter AS much right now. I’m mostly curious about how and why npm has transcended node.js.
@smchughinfo: I answered your question about your post being flagged in your other support question.
As for this one, I moved it to the development category as it’s more of a discussion that an issue with the platform.
Lastly, I feel that the great answers from @williwyg are what you needed, but if you want more information and continue the discussion, feel free to ask more question in this thread.
Can you please just delete this question. It’s actually still entirely unanswered as far as I am concerned but I do appreciate @williwyg’s reply.
If you don’t think it’s still useful for you, maybe it can be for others? I also would find it sad to throw away the time @williwyg spent trying to answer your question as there is valuable information in his answers.
Why not try to clarify your question @smchughinfo so we can help you?
I think your feeling that your question has not being answered might come from the fact that you do not have a clear view on Single Page Application Technology vs Server side rendering. If you are still living in the MVC server side rendering world than it is difficult to grasp the idee of why npm packages are important.
I would suggest you to read more about SPA technology to figure out the differences. As I already said once you get familiar with client side rendering and its advantages you probably never wonna go back to server side rendering.