我已经在我的项目中安装了一个第三方库,但它不工作,所以我想从我的项目中删除该库, 我该怎么做?
npm uninstall --save package_name
npm uninstall --save-dev package_name
rnpm unlink package_name
注意 rnpm 已被废弃
I followed the following steps:--
react-native unlink <lib name>——这个命令已经从两个平台解除了库的链接。
react-native unlink <lib name>
react-native uninstall <lib name>——这已经从节点模块及其依赖项卸载了库
react-native uninstall <lib name>
Manually removed the library name from package.json——不知为什么—— save 命令在从 package.json 中删除库声明时不起作用。
Manually removed the library name from package.json
在此之后,我已经手动删除 空荡荡的反应本机库从节点 _ 模块文件夹
If you want to unlink already installed packages in react native
$ react-native unlink package_name
$ yarn remove package_name
如果您在第一步之前执行第二步,您需要安装相关的软件包回来,并执行第二步
我将在这里张贴我的答案,因为它是在谷歌搜索的第一个结果
1) react-native unlink <Module Name>
react-native unlink <Module Name>
2) npm unlink <Module Name>
npm unlink <Module Name>
3) npm uninstall --save <Module name
npm uninstall --save <Module name
来自 本能反应,救命
uninstall [options] uninstall and unlink native dependencies
react-native uninstall react-native-vector-icons
它将卸载和取消其依赖项的链接。
你必须检查你的链接项目,在新版本的 RN,不需要链接,如果你链接它造成一个问题, I Fixed the problem by unlinked manually the dependency that I linked and re-run.
You can delete installed react native package with this command.
npm uninstall package_name
例如:
npm uninstall react-native-camera
从 package.json文件中删除包名
package.json
删除 package-lock.json文件
package-lock.json
然后运行 npm install
npm install
or you can run the following command to uninstall any package
Npm 卸载 package _ name
For iOS...
Remove the node package and install the pods.
如果使用 npm: 卸载软件包名称
如果你在使用纱线: 除纱包装名称
然后简单地用以下命令安装吊舱: Npx pod-install
通常 package.json 目录位于项目文件夹的根目录中,因此应该从那里运行这些文件。Npx pod-install 将转到您的 ios 文件夹并运行 pod install。如果不添加/删除本机组件,则不需要运行此步骤。
我认为对于 Android 来说可能是相同的步骤,但是不运行后一个命令,因为 Android 不使用 cocoapods。
简单易行的解决方案。
npm uninstall --save react-native-image-slider-box
All of the top answers are a bit outdated. They do work, but the process could be better. So I'm going to post a more modern and 'normal' way.
Assumptions:
react-native unlink
react-native link
如果您的软件包安装时没有手动编辑本机文件(如 android/settings.gradle、 ios/yourappname/AppDelegate.m等)或任何其他配置(如 mypackage.config.js) ,那么您应该这样做:
android/settings.gradle
ios/yourappname/AppDelegate.m
mypackage.config.js
npm uninstall <yourpackage>
yarn remove <yourpackage>
cd ios && pod install && cd ..
如果您确实需要手动编辑本机文件或任何其他额外配置来安装软件包,那么:
这是一个好主意,以获得所有的信息,你可以确切地做了当你安装软件包。你能学到的任何额外的上下文都是好的。
撤消安装软件包时所做的手动更改。理想情况下,使用 git diff 或 git GUI 程序来帮助您解决这个问题。因为这个过程根据软件包和您实际做了什么而有所不同,所以很难说得更具体一些。
如果使用 npm,运行 npm uninstall <yourpackage>。如果使用纱线,运行 yarn remove <yourpackage>。
运行 cd ios && pod install && cd ..
That's it, done. If things are not good at this point, then something is very wrong.
记住,如果你觉得这对你有帮助的话,就给它投上一票,这样它就会更加明显。谢谢!
卸载本地软件包: Npm 卸载 < package _ name > 例如: Npm 卸载 response-本机 webview
卸载全局软件包: npm uninstall -g <package_name> 例如: Npm 卸载-g response-本机-webview