How do I use NPM for JavaScript packages?

52 views
Skip to first unread message

Quin Lee

unread,
Jan 30, 2016, 2:14:06 AM1/30/16
to nodejs
I need to download JavaScript libraries for use in my website.  The website is not being built using Node.  However, some of the JavaScript packages that I need to install are available through NPM.  Can NPM be used to download packages for regular HTML and JavaScript websites?  The NPM website states that it's the package manager for almost everything.  However, it seems to only provide Node packages.  

Below is a link to one of the JavaScript libraries that I am using for my site (built w/ React.js).

Luiz Filipe Freitas Carneiro

unread,
Jan 30, 2016, 4:41:32 PM1/30/16
to nod...@googlegroups.com
You can do it using browserify in order to require your dependencies dowloaded from npm to use inside your client side application or website

De: Quin Lee
Enviada em: ‎30/‎01/‎2016 04:14
Para: nodejs
Assunto: [nodejs] How do I use NPM for JavaScript packages?

I need to download JavaScript libraries for use in my website.  The website is not being built using Node.  However, some of the JavaScript packages that I need to install are available through NPM.  Can NPM be used to download packages for regular HTML and JavaScript websites?  The NPM website states that it's the package manager for almost everything.  However, it seems to only provide Node packages.  

Below is a link to one of the JavaScript libraries that I am using for my site (built w/ React.js).

--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/03669ad0-4961-49f6-8ff2-0032903f8ec9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Zlatko

unread,
Jan 31, 2016, 10:39:21 AM1/31/16
to nodejs
Of course you can use npm to download general JavaScript packages, and you can use them in the browser, if nothing, then manually.

The simplest use case: 

    npm install griddle-react --save

That installs the pacakge in node_modules/griddle-react folder.

From there you can simply include the script in your HTML:

    <script src="node_modules/griddle-react/build/griddle.js">

But as Luiz has said,if you use something like browserify or webpack to also resolve the dependencies automatically, it gets even simple to use these things.

Angel Java Lopez

unread,
Jan 31, 2016, 12:58:34 PM1/31/16
to nod...@googlegroups.com
You also can use bower


Maybe, it is more aligned with your use case. Think it as a "npm for the browser"

Angel "Java" Lopez
@ajlopez


--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages