6

I was reading a document about npm Developer Guide.
I was wondering if it is possible to write a web client application using javascript/css/html by using npm?
If yes, are there some example on github?

For example my client web application depends on requirejs, jquery, underscore and backbone.
Can I use npm to automatically download, in the vendor directory, the latest version of requirejs, jquery, underscore and backbone ?
If not, are there other tools/methods to accomplish this goal?

2
  • NPM is just a package manager like apt or nuget so as long as the package you use has client-side support it should work just fine. Other useful packages can be used without a browser like uglifyjs or jshint. I don't think your question is clear enough. Commented Sep 18, 2012 at 10:43
  • @elclanrs you are right. I rephrased my question with an example. thanks. Commented Sep 18, 2012 at 10:47

4 Answers 4

6

Yeoman uses a package manager called Bower to manage dependencies - the Bower Github page gives an example of downloading jQuery for a project, so this might be useful for your projects.

Sign up to request clarification or add additional context in comments.

Comments

1

Okay, now your question becomes clear. Yes, you can use NPM to help you develop JavaScript for the front-end. There are lots of tools available that will make your workflow much smoother. I mentioned jshint and uglifyjs already, but you have grunt to do a bunch of useful tasks, less and sass compilers, and the list goes on. To manage dependencies in CommonJS you'd typically use a package.json.

2 Comments

thanks for your answer. Actually I am not sure ` grunt ` fits my purpose or maybe I didn't understand it. The only tool which seems good to me is bower.
Look in here npmjs.org. There are literally over 14.000 packages so I'm pretty sure you'll find something that fits your needs.
0

An example is my Pretty Diff tool. It works equally well on the client side and I distribute it via NPM. A well written JavaScript application will run absolutely anywhere there is a JavaScript interpreter regardless of the environment. The way to accomplish this is to separate the application code from any APIs. In the case of my application I use the following APIs:

  • DOM - web browser
  • WSH - Windows command line
  • Node.js - Node.js

Comments

-3

Long version:

npm is a manager for packages used by nodejs, which is a program for running javascript on serverside.

You can develop your own packages for nodejs and upload them to npm, or use it to install packages released by others, but those are only packages for nodejs, which is serverside, not clientside. So no, you cant use npm for what you want.

Version for really lazy people:

No, because npm is for nodejs, which is serverside, and thus it has nothing to do with clientside applications.

I hope this answers your question.

5 Comments

I got the point. I rephrased my question with an example. Anyway, are there other tools/methods/systems to accomplish this goal for the clientside application?
"npm stands for N-ode P-ackage M-anager" -- not according to this :: npmjs.org/doc/faq.html
@funkybro Woops, sorry. But it is the name of the package manager, so I am still somewhat right. Edited it now
But you can use npm for client-side libs.
(microsoft)nuget package manager know handle client stuff! why npm will not? thanks to @What i know now how to handle client stuff with npm to!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.