使用"npm install"安装依赖项时忽略特定的软件包 [英] Ignore a specific package while installing dependencies using 'npm install'

查看:1679
本文介绍了使用"npm install"安装依赖项时忽略特定的软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个节点软件包react-native-push-notification,为此我对软件包进行了一些更改以满足我的要求.但是,每次我执行npm install时,新的(原始包装,没有进行任何更改)包装都会与当前包装重叠.

I have a node package react-native-push-notification for which i have made some changes in the packages to fulfil my requirement. But every time i do a npm install the new (original package without my changes) package overlaps with my current package.

有什么办法可以限制npm install忽略修改后的程序包?我也想把这个包推到git.

Is there any way i can restrict npm install to ignore my modified package? And also i want to push this package to git.

任何潜在客户都将受到高度赞赏.

Any lead will be highly appreciated.

推荐答案

如果我对您的理解是正确的,则您对现有的节点程序包react-native-push-notification进行了一些更改,并且您希望使用自己的版本而不是原始版本.

If I understand you correctly you have made some changes to the already existing node package react-native-push-notification and you would rather use your own version of it than the original.

您有两种选择:

  • package.json中,更改react-native-push-notification指向您的git repo(例如,您在github上的fork).这是不理想的,因为它使semver成为问题.但这有效.
  • 重命名该包的分支,并直接从npm中使用它.例如.重命名为react-native-push-notification2甚至更好,请使用有范围的软件包名称,例如@yournick/react-native-push-notification并将其发布到npm.将您的package.json更改为使用此软件包.
  • 说服原始软件包的作者合并您的更改.这是理想的解决方案,但可能很难合并您的补丁等.
  • In package.json change react-native-push-notification to point to your git repo (e.g. your fork on github). This is not ideal since it makes semver problematic. But it works.
  • Rename your fork of the package and use that directly from npm. E.g. rename to react-native-push-notification2 or even better, use a scoped package name e.g. @yournick/react-native-push-notification and publish that to npm. Change your package.json to use this package instead.
  • Convince the authors of the original package to incorporate your changes. This is the ideal solution, but might be difficult to get your patch merged etc.

这篇关于使用"npm install"安装依赖项时忽略特定的软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆