From ec9d33dfcfe11ef90a3634e415e7110ed78cadf5 Mon Sep 17 00:00:00 2001 From: Peter Velkov Date: Tue, 9 Aug 2022 20:27:08 +0300 Subject: [PATCH] package.json: prefix run `react-native` through `npx` Some clarity on npx: - it works a bit differently in npm 6 (which we currently use) - namely it downloads and executes a package without the user confirming first. - it would not download a package if it's available locally in node_modules/.bin - right now it downloads react-native every time because it's missing from .bin - it works pretty much like npm run Using npx does not mean "always run with the latest version" of the given package, but "use any local version we have (.bin), or download it otherwise) npx would use the latest version only when we don't have a package installed locally This means that adding the npx prefix would help fix the problem quickly now And would make no difference when we switch to newer node and npm later, because the react-native package would be avaialable in node_modules/.bin (The problem is `react-native` is not being recognized as installed in package scripts. The source of the problem is using npm6 which is now a bit obsolete) (More details in this slack thread: https://expensify.slack.com/archives/C01GTK53T8Q/p1659765865205259) --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 6308ee32b8b8..42b11049f83e 100644 --- a/package.json +++ b/package.json @@ -8,12 +8,12 @@ "private": true, "scripts": { "postinstall": "scripts/react-native-web.sh && cd desktop && npm install", - "clean": "react-native clean-project-auto", - "android": "npm run check-metro-bundler-port && scripts/set-pusher-suffix.sh && react-native run-android", - "ios": "npm run check-metro-bundler-port && scripts/set-pusher-suffix.sh && react-native run-ios", - "ipad": "npm run check-metro-bundler-port && react-native run-ios --simulator=\"iPad Pro (12.9-inch) (4th generation)\"", - "ipad-sm": "npm run check-metro-bundler-port && react-native run-ios --simulator=\"iPad Pro (9.7-inch)\"", - "start": "react-native start", + "clean": "npx react-native clean-project-auto", + "android": "npm run check-metro-bundler-port && scripts/set-pusher-suffix.sh && npx react-native run-android", + "ios": "npm run check-metro-bundler-port && scripts/set-pusher-suffix.sh && npx react-native run-ios", + "ipad": "npm run check-metro-bundler-port && npx react-native run-ios --simulator=\"iPad Pro (12.9-inch) (4th generation)\"", + "ipad-sm": "npm run check-metro-bundler-port && npx react-native run-ios --simulator=\"iPad Pro (9.7-inch)\"", + "start": "npx react-native start", "web": "scripts/set-pusher-suffix.sh && concurrently npm:web-proxy npm:web-server", "web-proxy": "node web/proxy.js", "web-server": "webpack-dev-server --open --config config/webpack/webpack.dev.js",