cli icon indicating copy to clipboard operation
cli copied to clipboard

Cannot run program "\node_modules\@react-native-community\cli\build\bin.js": CreateProcess error=193, %1 nÒo Ú um aplicativo Win32 vßlido

Open tony-tsx opened this issue 6 years ago • 30 comments

Environment

System: OS: Windows 10 10.0.17763 CPU: (4) x64 Intel(R) Core(TM) i5-3337U CPU @ 1.80GHz Memory: 610.45 MB / 7.90 GB Binaries: Node: 13.5.0 - C:\Program Files\Bins\node-v13.5.0-win-x64\node.EXE Yarn: 1.20.0-20190930.1131 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.13.4 - C:\Program Files\Bins\node-v13.5.0-win-x64\npm.CMD SDKs: Android SDK: API Levels: 22, 23, 26, 27, 28, 29 Build Tools: 28.0.3, 29.0.2 System Images: android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom IDEs: Android Studio: Version 3.5.0.0 AI-191.8026.42.35.5977832 npmPackages: react: 16.9.0 => 16.9.0 react-native: 0.61.5 => 0.61.5

Description

new project using react-native-cli I came across an error:

: ReactNative: Running 'PROJECT_DIR \node_modules@react-native-community\cli\build\bin.js config' command failed.

FAILURE: Build failed with an exception.

  • Where: Script 'PROJECT_DIR\node_modules@react-native-community\cli-platform-android\native_modules.gradle' line: 160

  • What went wrong: A problem occurred evaluating script.

Cannot run program "PROJECT_DIR\node_modules@react-native-community\cli\build\bin.js": CreateProcess error = 193,% 1 is not a valid Win32 application

As the error itself accuses. has a 'PROJECT_DIR\node_modules@react-native-community\cli-platform-android\native_modules.gradle' failure, when it attempts to run 'PROJECT_DIR\node_modules@react-native-community\cli\build\bin.js config' by Runtime.getRuntime().exec in .gradle

got a result by doing a jerry-rigged checking if the command being passed to

getCommandOutput (String command)

is the same as 'PROJECT_DIR\node_modules\@react-native-community\cli\build\bin.js config', and if true then the def cmdProcess variable would receive Runtime.getRuntime().exec ("node" + command)

cmdProcess = Runtime.getRuntime().exec ("node" + command)

if not by default Runtime.getRuntime().exec(command). At first it was a solution but nothing correct.

@react-native-community\cli-platform-android\native_modules.gradle line 154

In other words, when the command is being passed, it is not being executed with nodejs, but tried to execute the file by itself in the system.

I would like to report this.

Note: I apologize for the informality, it is the first time that I make an issue if I have a mistake I apologize and I will be listening to any comments.

def cmdProcess
if ( command.contentEquals( "PROJECT_DIR\\node_modules\\@react-native-community\\cli\\build\\bin.js config" ) ) cmdProcess = Runtime.getRuntime().exec( "node " + command )
else cmdProcess = Runtime.getRuntime().exec(command)

Note: I used google translate.

Reproducible Demo

react-native init --template typescript yarn android

tony-tsx avatar Feb 13 '20 21:02 tony-tsx

#945

tony-tsx avatar Feb 13 '20 21:02 tony-tsx

Shebang doesn't work on Windows - really annoying error. Your workaround is a correct fix.

https://stackoverflow.com/questions/33509816/what-exactly-does-usr-bin-env-node-do-at-the-beginning-of-node-files

I'll send a PR in a second.

grabbou avatar Feb 13 '20 21:02 grabbou

Fixed as of 3.1.1 of cli-platform-android package. Please reinstall node_modules and remove lockfiles.

@tony-tsx, please let me know if it works. What's your command line tool? Powershell? In case you run into any other issues, I'd appreciate your debugging and we will ship fixes right away.

grabbou avatar Feb 13 '20 22:02 grabbou

Once you confirm the fix, I will release this to 4.x channel too.

grabbou avatar Feb 13 '20 22:02 grabbou

Fixed as of 3.1.1 of cli-platform-android package. Please reinstall node_modules and remove lockfiles.

@tony-tsx, please let me know if it works. What's your command line tool? Powershell? In case you run into any other issues, I'd appreciate your debugging and we will ship fixes right away.

Thanks. i'm using powershell, i'll be in a minute. Anything notice here.

tony-tsx avatar Feb 13 '20 23:02 tony-tsx

I tried deleting all my lock files and reinstalling node modules, still getting the same error

nikhilbatta avatar Feb 14 '20 01:02 nikhilbatta

@grabbou still running into the same problem, let me know what else I can do to fix this.

nikhilbatta avatar Feb 14 '20 01:02 nikhilbatta

@nikhilbatta try verifying that your version of cli-platform-android was updated to 3.1.1. When I just re-installed @react-native-community/cli it installed 3.1.0, I had to explicitly install @react-native-community/[email protected].

amduffy19 avatar Feb 14 '20 01:02 amduffy19

@amduffy19 I have the right versioning which is 3.1.1 and its still giving me the same error.

nikhilbatta avatar Feb 14 '20 01:02 nikhilbatta

can i see what your packagejson looks like ?

nikhilbatta avatar Feb 14 '20 01:02 nikhilbatta

@nikhilbatta are you sure it's the same error?

sclavijo93 avatar Feb 14 '20 01:02 sclavijo93

@sclavijo93

  • What went wrong: A problem occurred evaluating script.

internal/modules/cjs/loader.js:626 throw err; ^Error: Cannot find module '@react-native-community/cli'Require stack:- C:\Users\NikhilBatta\Desktop\throwaway\wellifynative\android[eval] at Function.Module._resolveFilename (internal/modules/cjs/loader.js:623:15) at Function.Module._load (internal/modules/cjs/loader.js:527:27) at Module.require (internal/modules/cjs/loader.js:681:19) at require (internal/modules/cjs/helpers.js:16:16) at [eval]:1:13 at Script.runInThisContext (vm.js:123:20) at Object.runInThisContext (vm.js:313:38) at Object. ([eval]-wrapper:9:26) at Module._compile (internal/modules/cjs/loader.js:774:30) at evalScript (internal/process/execution.js:78:25) { code: 'MODULE_NOT_FOUND', requireStack: [ 'C:\Users\NikhilBatta\Desktop\throwaway\wellifynative\android\[eval]' ]}

nikhilbatta avatar Feb 14 '20 01:02 nikhilbatta

@nikhilbatta That looks like a different error. Try npm install @react-native-community/cli or add @react-native-community/cli to package.json and re-install node-modules

amduffy19 avatar Feb 14 '20 01:02 amduffy19

@nikhilbatta try deleting both node_modules and your .lock file then add this to your package.json

"resolutions": {
    "@react-native-community/cli-platform-android": "2.9.0"
  },

then run yarn or npm install

(https://stackoverflow.com/questions/60218063/no-such-file-or-directory-open-app-build-intermediates-merged-manifests-debug#)

sclavijo93 avatar Feb 14 '20 01:02 sclavijo93

yup thats the thing that i am trying right now. @sclavijo93

nikhilbatta avatar Feb 14 '20 01:02 nikhilbatta

@nikhilbatta That's weird.. that solution is working for me

sclavijo93 avatar Feb 14 '20 01:02 sclavijo93

I think it worked, thank you bros. @amduffy19 @sclavijo93

nikhilbatta avatar Feb 14 '20 01:02 nikhilbatta

Nice! You're welcome @nikhilbatta and thanks to you too @amduffy19

sclavijo93 avatar Feb 14 '20 01:02 sclavijo93

@nikhilbatta try deleting both node_modules and your .lock file then add this to your package.json

"resolutions": {
    "@react-native-community/cli-platform-android": "2.9.0"
  },

then run yarn or npm install

@amduffy19

nikhilbatta avatar Feb 14 '20 02:02 nikhilbatta

im getting this error now, after i ran gradle clean i got this. such file or directory, open 'app\build\intermediates\merged_manifests\debug\AndroidManifest.xml

nikhilbatta avatar Feb 14 '20 02:02 nikhilbatta