使用"npm install"安装依赖项时忽略特定的软件包 [英] Ignore a specific package while installing dependencies using '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
changereact-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 yourpackage.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屋!