Cli: Is npx needed?

Created on 12 Dec 2019  路  6Comments  路  Source: react-native-community/cli

The server used to build our app doesn't have npx installed and we would prefer not installing it. Is there any benefit to using npx instead of just calling the react-native binary directly? The one in node_modules/.bin/react-native? Seems to me it accomplishes the same thing without the need for npx.

question

Most helpful comment

@cpojer we'll migrate off of npx, it's causing too many issues.

All 6 comments

npx binary is assumed to be bundled with Node, that's why we use it. Calling node_modules/.bin/react-native is not easily portable in monorepos and across OSes (like Windows). Did you specifically remove it in your environment?

@thymikee We noticed this specifically at Facebook in an app that consumes React Native from open source rather than our internal version and therefore is using the cli packages which our internal version doesn't. We do not have npx or internet access available there. I think the offending line is this one: https://github.com/react-native-community/cli/blob/4fefe6b0e661cae1217267ed939c8967bf7c913a/packages/platform-android/native_modules.gradle#L187

Could we provide a fallback or a way to configure this? What if we invoked node instead by taking a look at something like require.resolve('react-native/' + require('react-native/package.json').bin)?

@cpojer we'll migrate off of npx, it's causing too many issues.

@thymikee do you know how long before we have access to the non-npx version? This is preventing us from upgrading to RN 0.61 :(

@grabbou, thanks for working on this! How does your fix relates to this:

https://github.com/facebook/react-native/blob/1fb815ed4314c1396999e64354ca0b5d4ed83663/react.gradle#L102 ?

Is this a separate issue?

@dalmendray, we're removing that as of 0.63. See the linked #28415 for discussion.

Was this page helpful?
0 / 5 - 0 ratings