Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mp3 file error #6527

Closed
ghost opened this issue Mar 18, 2016 · 11 comments
Closed

mp3 file error #6527

ghost opened this issue Mar 18, 2016 · 11 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@ghost
Copy link

ghost commented Mar 18, 2016

Adding an mp3 file into the project directory, running npm start, and reloading the application results in this error:

[10:55:08 AM] <START> request:/index.ios.bundle?platform=ios&dev=true
TypeError: unsupported file type
    at lookup (/Users/user/Dev/Apps/app/node_modules/image-size/lib/index.js:35:9)
    at /Users/user/Dev/Apps/app/node_modules/image-size/lib/index.js:93:22
    at /Users/user/Dev/Apps/app/node_modules/image-size/lib/index.js:50:9
    at /Users/user/Dev/Apps/app/node_modules/graceful-fs/graceful-fs.js:43:10
    at FSReqWrap.oncomplete (fs.js:82:15)

It seems like RN thinks the mp3 file is an image file, but because it is an unknown image type, image-size is throwing an error. The file has the .mp3 extension. How do I fix this issue?

  • RN v0.21.0
  • iOS
  • Mac
@jaygarcia
Copy link
Contributor

This is strange. Are you trying to include the file in your project at all?

@ghost
Copy link
Author

ghost commented Mar 19, 2016

I drop the file into my Xcode project and check both 'Copy item into it' and set target to my app. The same happens if I put the file outside the iOS folder.

It seems to happen to any file with audio extension; I've tried wav, mp3, mp4. They all throw the same error. I fixed the issue by removing the file extension. So I just use 'abc' instead of 'abc.mp3'.

Interestingly, I created a new RN project and this doesn't happen. My project was created with RN 0.19.0 and I recently upgraded to 0.21.0. The only thing I can think of is that something didn't go right during the upgrade, since new projects created with 0.21.0 doesn't seem to have the same problem.

@jsierles
Copy link
Contributor

Perhaps you had an older version of the packager running?

Since this is not a problem with a standard install of 0.21, let's close this and see if it pops up again.

@ghost
Copy link
Author

ghost commented Mar 20, 2016

@jsierles The problem was with not running react-native upgrade. More specifically .flowconfig needed module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\)$' -> 'RelativeImageStub'

@arianitu
Copy link

I upgraded to 0.22 and I get TypeError: unsupported file type on node_modules/clone/test.html

What's that about?

@ghost
Copy link
Author

ghost commented Mar 25, 2016

@arianitu check if html is in .flowconfig file's module.name_mapper

@arianitu
Copy link

I was still using the old image API, like this:

<Image source={require('image!test')} />

This use to pull from Images.xcassets, but now it seems to pull from the project directory and found the test.html file inside of node_modules/clone/test.html

I think the fix is to move all assets out from xcassets and put them in my project and require them that way.

What a really confusing error, it was really hard to track down since it had no indication that this had anything to do with the image api.

@arianitu
Copy link

After converting to the new image API, I no longer get TypeError: unsupported file type and my project works.

@toearth
Copy link

toearth commented Jun 13, 2016

[16:07:54] <START> request:/index.ios.bundle?platform=ios&dev=true TypeError: unsupported file type at lookup (node_modules/image-size/lib/index.js:35:9) at node_modules/image-size/lib/index.js:93:22 at node_modules/image-size/lib/index.js:50:9 at node_modules/graceful-fs/graceful-fs.js:43:10

I got the same error when I use the 0.27.2.

@toearth
Copy link

toearth commented Jun 13, 2016

I have solved this problem by use new image api {uri: 'app_icon'}

@unmec
Copy link

unmec commented Apr 5, 2017

I had the same problem and curiously I have only to use {{uri:'image.png'}} for images that have nested contents, then it worked.

@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

6 participants