Skip to content

Instantly share code, notes, and snippets.

@FLGMwt
Last active March 25, 2026 22:19
Show Gist options
  • Select an option

  • Save FLGMwt/902916867d7dd3926345e63b0d2a5bbc to your computer and use it in GitHub Desktop.

Select an option

Save FLGMwt/902916867d7dd3926345e63b0d2a5bbc to your computer and use it in GitHub Desktop.
RN upgrade helper to npm i command
// helper script for generating an `npm install` command for packages chagnes when @rnx-kit/align-deps is bad
// given example for:
// https://react-native-community.github.io/upgrade-helper/?from=0.82.1&to=0.83.4
const packages = {
// copy & paste from https://react-native-community.github.io/upgrade-helper's package.json green lines
// following example from https://react-native-community.github.io/upgrade-helper/?from=0.82.1&to=0.83.4
// HEY YOU!
// replace the following with your output:
react: "19.2.0",
"react-native": "0.83.4",
"@react-native/new-app-screen": "0.83.4",
"@react-native/babel-preset": "0.83.4",
"@react-native/eslint-config": "0.83.4",
"@react-native/metro-config": "0.83.4",
"@react-native/typescript-config": "0.83.4",
"@types/react": "^19.2.0",
"react-test-renderer": "19.2.0",
// END HEY YOU!
};
const rejectionPredicates = [
// idk, sometimes it's helpful to just copypasta what the website tells you and
// me, the script maintainer saying "no you don't need this" without you having to
// worry about that just reading the upgrade helper
/* eslint-disable @typescript-eslint/no-unused-vars */
( [packageName, version] ) => packageName === "@react-native/new-app-screen",
/* eslint-enable @typescript-eslint/no-unused-vars */
];
const packageList = Object
.entries( packages )
.filter( packageTuple => !rejectionPredicates.some( predicate => predicate( packageTuple ) ) )
.map( ( [packageName, version] ) => `"${packageName}@${version}"` )
.join( " " );
const command = `npm install --save-exact ${packageList}`;
console.log( command );
// sample output:
// npm install --save-exact "react@19.2.0" "react-native@0.83.4" "@react-native/babel-preset@0.83.4" "@react-native/eslint-config@0.83.4" "@react-native/metro-config@0.83.4" "@react-native/typescript-config@0.83.4" "@types/react@^19.2.0" "react-test-renderer@19.2.0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment