简体   繁体   English

如何在Angular2中使用软件包而不将其发布到npm

[英]How to use a package in Angular2 without publishing it to npm

I have a package which is published to npm and we are successfully using the package in our angular2 applications by defining the dependency in package.json as 我有一个发布到npm的软件包,通过在package.json中定义依赖项,我们可以在angular2应用程序中成功使用该软件包:

"dependencies": {
   "somesharedmodule": "^1.0.21",
 }

and in our components as import {SharedService} from 'somesharedmodule' . 并在我们的组件中import {SharedService} from 'somesharedmodule'

Now we dont want to make the library public(not interested to make private library too).My question is - i have a module in some folder of my local system.Can i use this module in my application without making the package published in npm. 现在我们不想公开该库(也不希望建立私有库)。我的问题是-我在本地系统的某个文件夹中有一个模块。我可以在我的应用程序中使用此模块而无需使该软件包在npm中发布吗? 。 can somebody please guide me the alternatives to use a module in my application without publishing it? 有人可以指导我在我的应用程序中使用模块而不发布它的替代方法吗?

Not clear what exactly you want to do... Bu there are lots of options: 不清楚您到底想做什么... Bu有很多选择:

  • npm link https://docs.npmjs.com/cli/link npm链接https://docs.npmjs.com/cli/link
  • use github private repo: 使用github私有仓库:

    "dependencies": { "ng2-resource": "https://github.com/{nickName}/{repoName}.git" }

  • link your IDE to use local folder as node_modules 链接您的IDE以将本地文件夹用作node_modules

  • manually copy/paste library into project's node_modules 手动复制/粘贴库到项目的node_modules

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

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