如何配置React Native init默认node_modules,移除默认安装的eslint-plugin-react-native
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.jsonto removeeslint-plugin-react-nativefrom dependencies or devDependencies. - Initialize your project with the custom template using:
This way, every new project will use your modified template without the unwanted plugin.react-native init MyNewApp --template file:///path/to/your/custom/template-folder
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-nativepackage directory (usually in~/npm/lib/node_modules/react-nativeor similar, depending on your npm setup). - Navigate to
templates/BasicTemplate/package.jsonand removeeslint-plugin-react-nativefrom the dependency list. - Note: This change will be overwritten the next time you update the global
react-nativeCLI, 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

