简体   繁体   中英

How to develop client side library and npm library ?

I would like to develop a JS test library for client & node. I need to develop for two different repo's? Lets take for example QUnit : for client side I will use:

https://code.jquery.com/qunit/qunit-2.3.0.js

But for node develop, I will use :

npm install qunitjs

Those are 2 different code repo's, aren't?

For the example, lets puts aside the testrunner, etc..

Thanks!

Originally the "npm" used to stand for the "Node Package Manager".

Currently, the npm Registry is a public collection of packages of open-source code for Node.js, front-end web apps, mobile apps, robots, routers, and countless other needs of the JavaScript community.

And npm is the command line client that allows developers to install and publish those packages.

See: https://www.npmjs.com/about

So you can use npm to package front-end code just like you can use npm to package Node code. Sometimes it makes sense to publish two packages - one for frontend and one for backend - but sometimes you can have just one.

For packaging frontend code there are more options like Bower: https://bower.io/

For packaging Node code the most popular choice is npm but you can install code directly from GitHub or other git repos.

As an example you can see my module tco that is on npm:

But also on GitHub:

So you could install it with npm either from the npm Registry or from GitHub:

npm install tco           # <-- from npm registry
npm install rsp/node-tco  # <-- from github

Additionaly you can use it on the frontend from the CDN available for all code on GitHub:

<script src="https://cdn.rawgit.com/rsp/node-tco/v0.0.12/tco.min.js"></script>

If you want your code available on that CDN as well, see RawGit:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM