Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm for javascript client side code

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?

like image 938
Lorraine Bernard Avatar asked Sep 18 '12 10:09

Lorraine Bernard


People also ask

Can JavaScript be used for client side?

HTML pages with server-side JavaScript can also include client-side JavaScript. In contrast to pure client-side JavaScript pages, HTML pages that use server-side JavaScript are compiled into bytecode executable files. These application executables are run by a web server that contains the JavaScript runtime engine.

Can you use npm in JavaScript?

What is NPM? NPM is the default package manager for node. It is used to install, share, and manage javascript packages in a project.

How do I use npm client side packages?

Using npm to install dependenciesExecute command npm install . This command would read package. json and install dependencies jquery and bootstrap. A new directory called node_modules should have been created and directories jquery and bootstrap should have been created inside node_modules .

What is npm for JavaScript?

npm (originally short for Node Package Manager) is a package manager for the JavaScript programming language maintained by npm, Inc. npm is the default package manager for the JavaScript runtime environment Node.js.


Video Answer


2 Answers

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.

like image 86
whostolemyhat Avatar answered Oct 18 '22 11:10

whostolemyhat


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.

like image 37
elclanrs Avatar answered Oct 18 '22 11:10

elclanrs