'Requring invalid module "image!my-icon"' error when trying to include static image
When I try to require static assets as per http://facebook.github.io/react-native/docs/image.html#static-assets, I get the following error:
"Requring invalid module "image!my-icon". If you are sure the module is there, try restarting the packager."
Not sure if there are any steps I'm missing? I've included the asset in my Images.xcassets library
I don't know what is causing this issue, but ide in the irc told me to manually run:
$ node_modules/react-native/packager/packager.sh --assetRoots path/to/Images.xcassets
And that seems to work.
That didn't seem to do the trick unfortunately. Any other ideas of things I might have missed?
The above fix worked, thanks!
published v0.2.1
Where should I put the static assets then? in iOS/Images.xcassets?
@amasad it seems like the fix in #286 was later reverted by 31c4ff0? but fwiw I applied that diff manually to my packager and still couldn't get images to work. Inspecting the ReactPackager middleware to see if I can debug this further.
@pedro uggh that's clowny, I'll get it back shortly
brought this back in v0.3.1
That patch worked for me. @pedro did you do npm install react-native -g instead of npm install react-native -s by any chance?
@amasad It's a bit fragile, because node_modules can be pretty much anywhere relative to the xcode project.
@amasad has this bug definitely been closed ?
it originally didn't work, then worked for 2 days and now i've tried importing different images, on 3 different projects, and none work, even in the examples projects...
tried both launching default packager.sh and the command line where you specify assetRoots
always RED SCREEN: requiring unknown module...
Odd, still having issues here too. I have the react-native package installed locally with my app (under node_modules in the root folder).
ah, doh, was just using it wrong.
Not familiar with Images.xcassets, thought I needed to refer to images by the name of the group I defined in Xcode. But debugging the react-native packager I saw it still adds assets by the original image name, so using these instead works.
It should work now. But I know it's painful, working on making it a lot nicer.
Hi,
Now I seem to be facing the same issue, referring to the images by the image name does not work. E.g.
I have Avatar.png, [email protected], [email protected] in my Images.xcassets, and I use require('image!Avatar') does not work.
Any clues?
I also used this to launch, also does not work...
$ node_modules/react-native/packager/packager.sh --assetRoots path/to/Images.xcassets
I am also facing this problem, can't seem to get it to work, any ideas?
What are the errors you're seeing?
@amasad I am getting the error at the title of the thread. I did a bit more reading and named the image set the same as the file name of the image, and that seems to have fixed it.
Face the same problem....
@SatanWoo make sure you use the same name of the original filename as the name of your image set. That seemed to work for me.
same.. its not working. When you talk about node_modules/react-native/packager/packager.sh --assetRoots path/to/Images.xcassets
where should u run it from ?