How come this line works with no errors
var gicon = species[ii].color[0] ? require(\'../assets/gLight.jpg\') : require(\'../assets/nLight.png\');
Image names are resolved during packaging. There is a section about it in the docs. You can solve your problem by defining constants for the images:
const LIGHT_G = require('../assets/gLight.jpg');
const LIGHT_N = require('../assets/nLight.png');
which_light = LIGHT_G;
var gicon = species[ii].color[0] ? which_light : LIGHT_N;
You have to reference all possible images like this.