when use ctrl+p and run 'react native: run android' on Windows 10,this error occurs:
######### Attempting to start the React Native packager ##########
######### Packager is already running. ##########
[Warning] Debugging is not supported if the React Native Packager is not started within VS Code. If debugging fails, please kill other active React Native packager processes and retry.
######### Executing command: react-native.cmd run-android ##########
[Error : 0104] Failed to run the application in Android: Error while executing command 'react-native.cmd run-android': spawn react-native.cmd ENOENT
I install the same vs code to another computer , and it works well ,but on my computer ,it always show me this error ,what's wrong ?
We require that the react-native-cli be installed and globally available on the system. On the machine where it fails, run npm install -g react-native-cli and then it should work.
@MSLaguana thanks for your answer first , I reinstall the react-native-cli as you said, and reinstall the React Native Tools , the problem remains. the command React Native: Run Android can neither start the packager nor run app in Android :
######### Attempting to start the React Native packager ##########
######### Starting Packager ##########
[Error : 0104] Failed to run the application in Android: Could not start the packager.
I reinstall vs code last sunday, I've tried a lot to fix it , and it's useless. Now I have no choice but continue to use Android Studio to run my App └(T_T;)┘.
@herdotage Sorry for the delay.
react-native start and react-native run-android commands from the command line for that same project/computer?@digeff Sorry for the delay too, I got dumped last week ,it was a difficult time...
so , in the Node.js command prompt , react-native start and react-native run-android both works well ,the problem only occurs on my company's computer. the VS Code version is '0.10.11', extensions are React Native Tools and Reactjs code snippets ,etc. the same VS Code in other computer works well ,the same project also works well in that computer . it seems it's VS Code itself that has wrong, here is the console log:
Overwriting filename <<.jsx>> to now point to mime <<text/x-jsx>>
Cannot read property 'languageIds' of undefined: TypeError: Cannot read property 'languageIds' of undefined
at file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:98:5560
at Array.forEach (native)
at file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:98:5037
at Array.forEach (native)
at e._handler (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:98:5009)
at Object.listener (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:58:28803)
at e._triggerPointListener (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:58:30786)
at e.registerPlugins (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:58:31386)
at t.$onPluginHostReady (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:71:21766)
at t.e.handle (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:71:29651)
Overwriting filename <<.jsx>> to now point to mime <<text/x-jsx>>
TypeError: Cannot convert object to primitive value
at new Error (native)
at Client.trackException (C:\Program Files (x86)\Microsoft VS Code\resources\app\node_modules\applicationinsights\Library\Client.js:67:25)
at e.logException (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:23:30848)
at e.log (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:112:10791)
at t.handleEvent (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:68:2959)
at t.e.publicLog (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:68:144)
at t.publicLog (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:68:5186)
at t.e.flushErrorBuffer (file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:67:30198)
at file:///C:/Program Files (x86)/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:67:30058
Uncaught TypeError: Cannot convert object to primitive value
[Plugin Host] rejected promise not handled with 1 second
Error while executing React Native Packager.: spawn react-native.cmd ENOENT
Error while executing command 'react-native.cmd start --port 8081': spawn react-native.cmd ENOENT
WARNING: Promise with no error callback:undefined
TypeError: Cannot read property 'message' of undefined(…)
@herdotage What do you mean by the "Node.js command prompt"? Does react-native works in the Windows Command Prompt as in:
Start Menu ==> Command Prompt then:
C:\Users\herdotage> cd c:\your_workspace\your_project
react-native start
If that works, can you also try:
react-native.cmd start --port 8081
The ENOENT error code you are getting means that when we try to execute 'react-native.cmd start --port 8081' from inside the application, the spawn utility can't find the file react-native.cmd. The spawn utility uses the PATH environment variable to find the react-native.cmd file which in windows when you install react-native-cli globally is usually located at: %APPDATA%\npm\react-native.cmd
So running react-native.cmd start --port 8081 should be equivalent to run:
%APPDATA%\npm\react-native.cmd start --port 8081
The fact that you are getting ENOENT makes me think that either react-native-cli didn't install properly, or that the npm folder with all the .cmd files used for the npm modules CLIs isn't in your PATH variable.
You can run _echo %PATH%_ in the command line to see the contents of your path variable, and check if the npm folder with the react-native.cmd file is there.
@digeff Bingo, problem solved. My react-native.cmd located at %APPDATA%\Roaming\npmreact-native.cmd. In the past I run the react-native command via Node's command prompt ,not the system's. Hardly did I use the system's command prompt, but VS Code use it , when set the right PATH variable and restart my computer, the promblem solved.Thanks a lot for your answers.