Unhandled error when running react-native run android
throw er; // Unhandled 'error' event ^
Error: spawn cmd.exe ENOENT at _errnoException (util.js:1022:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19) at onErrorNT (internal/child_process.js:372:16) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9)
- Node.js Version: v8.9.4
- OS: Windows 10
- Scope (install, code, runtime, meta, other?):
- Module (and version) (if relevant):
are you on windows, or android? I guess cmd.exe does not exist in Android, so either you are running a windows specific module in Android or you may need an emulator software that implements a windows execution environment.
If you believe I did not understand your question, please elaborate what you are doing, what is expected behavior and what is actual, with probably a sample code.
Hope this helps.
Am working on windows 10 and running the application on an Android Emulator. It has been running ok but on Saturday it brought the erro message.
The expected behavior: When i run react-native run-android it should display the screens (views). For example it displays a login page which is connected to the backend.
The code below is for the New Assessment Page which fetches data from a jhpister back-end and displays on the dropdown menu (Pickers).
As of saturday when i run it throws the error message above and am not able to view the screen. The emulator also has an error.
Sample code: import React, { Component } from 'react' import { ScrollView, Text, Picker, TouchableOpacity, View} from 'react-native' import { connect } from 'react-redux' import { Actions as NavigationActions } from 'react-native-router-flux' // eslint-disable-line import { DatePickerDialog } from 'react-native-datepicker-dialog' import moment from 'moment'; import RoundedButton from '../Components/RoundedButton' // eslint-disable-line // Add Actions - replace 'Your' with whatever your reducer is called :) // import YourActions from '../Redux/YourRedux'
// Styles import styles from './Styles/NewAssessmentScreenStyle' import EnumeratorActions from '../Redux/EnumeratorRedux' import ParticipantActions from '../Redux/ParticipantRedux' import InterviewerTypeActions from '../Redux/InterviewerTypeRedux'
class NewAssessmentScreen extends Component {
state = { page: 0, sort: 'name,email,code,asc', size: 20, loading: true, done: false, dataObjects: [], }
constructor(props){ super(props); this.state = { DateText: '', DateHolder: null, isLoading: false, enumerator: '', participant:'', interviewerType:'', dataObjects:[], }; }
oneScreensWorth = 20
// Enumerator Functions- fetching enumerator names from the jHipster Backend
fetchEnumerators = () => {
this.props.getAllEnumerators({ page: this.state.page, sort: this.state.sort, size: this.state.size })
}
componentWillReceiveProps (newProps) {
if (newProps.enumerators) {
this.setState({
done: newProps.enumerators.length < this.state.size,
dataObjects: this.state.loading ? [...this.state.dataObjects, ...newProps.enumerators] : newProps.enumerators,
loading: false
})
}
}
componentDidMount () {
this.fetchEnumerators()
}
// Participant ID Functions- fetching from the jHipster Backend fetchParticipants = () => { this.props.getAllParticipants({ page: this.state.page, sort: this.state.sort, size: this.state.size }) }
componentWillReceiveProps (newProps) { if (newProps.participants) { this.setState({ done: newProps.participants.length < this.state.size, dataObjects: this.state.loading ? [...this.state.dataObjects, ...newProps.participants] : newProps.participants, loading: false }) } }
componentDidMount () { this.fetchParticipants() }
// Interviewee (Interviewer Type) Functions- fetching from the jHipster Backend fetchInterviewerTypes = () => { this.props.getAllInterviewerTypes({ page: this.state.page, sort: this.state.sort, size: this.state.size }) }
componentWillReceiveProps (newProps) { if (newProps.interviewerTypes) { this.setState({ done: newProps.interviewerTypes.length < this.state.size, dataObjects: this.state.loading ? [...this.state.dataObjects, ...newProps.interviewerTypes] : newProps.interviewerTypes, loading: false }) } } componentDidMount () { this.fetchInterviewerTypes() }
/**
- Textbox click listener */ DatePickerMainFunctionCall = () => {
let DateHolder = this.state.DateHolder;
if(!DateHolder || DateHolder == null){
DateHolder = new Date();
this.setState({
DateHolder: DateHolder
});
}
//To open the dialog
this.refs.DatePickerDialog.open({
date: DateHolder,
});
}
/**
- Call back for dob date picked event * */ onDatePickedFunction = (date) => { this.setState({ dobDate: date, DateText: moment(date).format('DD-MMM-YYYY') }); } render () {
return (
<ScrollView>
{//Enumerator Name Dropdown Menu
}
<Picker style={styles.picker}
itemStyle={styles.items}
selectedValue={this.state.selected}
onValueChange={(em) => this.setState({email:em})}>
{this.state.dataObjects.map((enumerator,index) => {return <Picker.Item key={enumerator.id} label={"Name of Enumerator: " + enumerator.email} value={enumerator.id} /> })}
</Picker>
{//Participant code Dropdown Menu
}
<Picker style={styles.picker}
itemStyle={styles.items}
selectedValue={this.state.name}
onValueChange={(cd) => this.setState({name: cd})}>
{this.state.dataObjects.map((participant) => {return <Picker.Item key={participant.code}
label={"Participant ID: " + participant.name} value={participant.code} /> })}
</Picker>
{//Calender Picker style
}
<View style={{flexDirection: 'row', alignItems: 'center'}}>
<Text style={styles.bold}>: Date of Assessment:</Text>
<View style={{flex:.5}}>
{//Calender picker for date of assessment
}
<TouchableOpacity onPress={this.DatePickerMainFunctionCall.bind(this)} >
<View style={styles.datePickerBox}>
<Text style={styles.datePickerText}>{this.state.DateText}</Text>
</View>
</TouchableOpacity>
{/* Place the dialog component at end of your views and assign the references, event handlers to it.*/}
<DatePickerDialog ref="DatePickerDialog" onDatePicked={this.onDatePickedFunction.bind(this)} />
</View>
</View>
{//interviewerType picker
}
<Picker style={styles.picker}
itemStyle={styles.items}
selectedValue={this.state.name}
onValueChange={(nm) => this.setState({name: nm})}>
{this.state.dataObjects.map((interviewerType) => {return <Picker.Item key={interviewerType.id} label={"interviewee: " + interviewerType.name} value={interviewerType.id} /> })}
</Picker>
<Picker
selectedValue={this.state.assessmentType}
onValueChange={(itemValue, itemIndex) => this.setState({assessmentType: itemValue})}>
<Picker.Item label="Child" value="child" />
<Picker.Item label="Adult: Female" value="female" />
</Picker>
<RoundedButton text='Start Child Assessment' onPress={NavigationActions.startAssessment} />
<RoundedButton text='Start Adult Assessment' onPress={NavigationActions.start1Assessment} />
</ScrollView>
)
} }
const mapStateToProps = (state) => { return {
// ...redux state to props here
participants: state.participants.participants,
fetching: state.participants.fetchingAll,
error: state.participants.errorAll,
// ...redux state to props here
interviewerTypes: state.interviewerTypes.interviewerTypes,
fetching: state.interviewerTypes.fetchingAll,
error: state.interviewerTypes.errorAll,
// ...redux state to props here
enumerators: state.enumerators.enumerators,
fetching: state.enumerators.fetchingAll,
error: state.enumerators.errorAll,
} }
const mapDispatchToProps = (dispatch) => {
return {
getAllParticipants: (options) => dispatch(ParticipantActions.participantAllRequest(options)),
getAllInterviewerTypes: (options) => dispatch(InterviewerTypeActions.interviewerTypeAllRequest(options)),
getAllEnumerators: (options) => dispatch(EnumeratorActions.enumeratorAllRequest(options)),
}
}
export default connect(mapStateToProps, mapDispatchToProps)(NewAssessmentScreen)
the emulator error:
Without the error(Usually it launches this screen then i am able to navigate to other screens)
without this JS code, are you able to issue cmd.exe in the emulator? If it does not work, then that needs to be fixed. I don't have much insight into that, but probably a configuration / path problem in the emulator.
closing as answered, please re-open if it is still outstanding, thanks!
if you are you sure, node.js is installed successfuly on your system, please check system environment variables and add C:\windows\system32 in system variables Paths
I solved the issue. Thank you
On Fri, Jun 8, 2018 at 1:06 AM guernica [email protected] wrote:
if you are you sure, node.js is installed successfuly on your system, please check system environment variables and add C:\windows\system32 in system variables Paths
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nodejs/help/issues/1172#issuecomment-395580645, or mute the thread https://github.com/notifications/unsubscribe-auth/Ad-4SnR9njE2rg_gqqH8PPcJzgIsM0M8ks5t6aPVgaJpZM4SvM1L .