You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置React Native init默认node_modules,移除默认安装的eslint-plugin-react-native

How to Stop eslint-plugin-react-native from Being Auto-Installed with react-native init

Hey there! I get why this is frustrating—you don't want that plugin cluttering up every new React Native project, and uninstalling it globally didn't fix the issue. Let's break down why that's happening and how to fix it for good.

Why global uninstall didn't work

The eslint-plugin-react-native package isn't being installed globally—it's part of the official React Native initialization template. When you run react-native init, it pulls the default template (shipped with the global react-native CLI) and installs all dependencies listed in that template's package.json, including this ESLint plugin. Uninstalling it globally doesn't affect the template's dependency list at all.

Solutions to remove it from default installs

1. Use a custom React Native template (recommended, permanent fix)

The cleanest way is to create your own minimal template that excludes the plugin, or use a community-maintained lightweight template:

  • First, find or create a template: You can clone the official React Native template repo, then edit its package.json to remove eslint-plugin-react-native from dependencies or devDependencies.
  • Initialize your project with the custom template using:
    react-native init MyNewApp --template file:///path/to/your/custom/template-folder
    
    This way, every new project will use your modified template without the unwanted plugin.

2. Automatically uninstall after initialization (quick temporary fix)

If you don't want to set up a custom template, you can chain commands to uninstall the plugin right after project creation:

react-native init MyNewApp && cd MyNewApp && npm uninstall eslint-plugin-react-native

You can even save this as a bash alias or small script to run it in one go every time.

3. Modify the global React Native template (not recommended)

You could directly edit the template files in your global react-native installation, but this is risky:

  • Locate the global react-native package directory (usually in ~/npm/lib/node_modules/react-native or similar, depending on your npm setup).
  • Navigate to templates/BasicTemplate/package.json and remove eslint-plugin-react-native from the dependency list.
  • Note: This change will be overwritten the next time you update the global react-native CLI, so it's only a temporary fix until your next update.

Final note

The custom template approach is the best long-term solution because it gives you full control over what gets installed in every new project. The chained command method is great for quick fixes if you don't want to mess with templates right now.

内容的提问来源于stack exchange,提问作者MoKhajavi75

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 10:15:37