[英]Visual Studio NodeJS Tools - How to Package Project? Create NPM?
I've got a VS2013 solution with a mix of NodeJS (using TypeScript) and C# class library projects (they're bound together by EdgeJS). 我有一个VS2013解决方案,其中混合了NodeJS(使用TypeScript)和C#类库项目(它们由EdgeJS绑定在一起)。 Where the NodeJS projects are concerned, one can be considered a library (for a RabbitMQ bus implementation), two are applications which are meant to be hosted as part of a fourth project with both using the bus. 在涉及NodeJS项目的地方,可以将一个视为库(对于RabbitMQ总线实现),两个是应作为第四项目的一部分托管的应用程序,两者均使用该总线。
So, one project ( host ) which will depend on three projects ( bus , app1 and app2 ) (it starts the bus , and passes it to app1 and app2 ). 因此,一个项目( 主机 )将依赖于三个项目( bus , app1和app2 )(它将启动bus并将其传递给app1和app2 )。
Of course, I could just lump all these projects together and be done with it - but that's a horrible idea. 当然,我可以将所有这些项目放在一起并完成它-但这是一个可怕的想法。
How do I package these projects up for proper reuse and referencing (like assemblies in traditional .NET)? 如何打包这些项目以进行正确的重用和引用(如传统.NET中的程序集)?
Is that best done with NPM? NPM最好做到吗? If so, does VS provide anything in this area? 如果是这样,VS是否在这方面提供任何服务? If not, then what? 如果没有,那又如何?
Note that, aside from the Bus project, I'm not looking to release these publicly - I'm not sure if that changes anything. 请注意,除了Bus项目外,我不想公开发布这些内容-我不确定这是否会改变任何内容。
In general, if something can be bundled together as an independent library, then it's best to consider this a Node package and thus, refactor that logic out to it's own project. 通常,如果可以将某些东西捆绑在一起作为一个独立的库,那么最好将其视为Node包,从而将逻辑重构到自己的项目中。 It sounds like you've already done this to some extent, separating out your bus
, app1
, and app2
projects. 听起来您已经完成了一定程度的工作,将bus
, app1
和app2
项目分离了出来。 I would recommend they each have their own Git repositories if they are separate packages. 如果它们是单独的软件包,我建议它们每个都有自己的Git存储库。
Here's some documentation to get you started with Node packages: https://www.npmjs.org/doc/misc/npm-developers.html 以下是一些文档,可帮助您开始使用Node软件包: https : //www.npmjs.org/doc/misc/npm-developers.html
The host
project, if it's not something you would package but instead deploy, probably does not need to be bundled as a Node package. host
项目,如果不是您要打包的东西,而是部署的话,可能不需要捆绑为Node包。 I would instead just consider this something that would be pulled down from Git and started on some server machine. 相反,我会考虑将其从Git下拉并在某些服务器上启动的东西。
With all that said, your last line is important: 综上所述,您的最后一行很重要:
I'm not looking to release these publicly 我不想公开发布这些内容
GitHub does have private repositories, but as of now npmjs.org does not have private repositories. GitHub确实有私有存储库,但是到目前为止npmjs.org还没有私有存储库。 There are options to create your own private repository ( Sinopia and Kappa offer different ways of accomplishing this), but if you don't want this code available for everyone do not deploy it do npmjs.org. 您可以选择创建自己的私有存储库( Sinopia和Kappa提供了不同的方法来实现此目的),但是如果您不希望每个人都可以使用此代码,请不要部署npmjs.org。 You can still package it up in the way I've outlined it above, just not deploy it as of yet. 您仍然可以按照我上面概述的方式打包它,只是暂时不部署它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.