简体   繁体   English

如何开发客户端库和npm库?

[英]How to develop client side library and npm library ?

I would like to develop a JS test library for client & node. 我想为客户端和节点开发一个JS测试库。 I need to develop for two different repo's? 我需要开发两个不同的回购协议吗? Lets take for example QUnit : for client side I will use: 让我们以QUnit为例 :对于客户端,我将使用:

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

But for node develop, I will use : 但是对于节点开发,我将使用:

npm install qunitjs npm安装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". 最初,“ npm”代表“节点程序包管理器”。

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. 当前,npm注册表是Node.js,前端Web应用程序,移动应用程序,机器人,路由器以及JavaScript社区无数其他需求的开源代码包的公共集合。

And npm is the command line client that allows developers to install and publish those packages. npm是命令行客户端,允许开发人员安装和发布这些软件包。

See: https://www.npmjs.com/about 请参阅: 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. 因此,您可以使用npm打包前端代码,就像可以使用npm打包Node代码一样。 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/ 对于打包前端代码,还有更多类似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. 对于打包Node代码,最受欢迎的选择是npm,但是您可以直接从GitHub或其他git repos安装代码。

As an example you can see my module tco that is on npm: 例如,您可以看到我的模块tco在npm上:

But also on GitHub: 而且在GitHub上:

So you could install it with npm either from the npm Registry or from GitHub: 因此,您可以通过npm Registry或GitHub上的npm安装它:

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: 另外,您可以在CDN的前端使用它,可用于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: 如果您希望代码也可以在该CDN上使用,请参见RawGit:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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