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

Module parse failed, possible invalid import from react-native? #1537

Closed
davisk4rpi opened this issue Feb 19, 2021 · 5 comments · Fixed by #1816
Closed

Module parse failed, possible invalid import from react-native? #1537

davisk4rpi opened this issue Feb 19, 2021 · 5 comments · Fixed by #1816

Comments

@davisk4rpi
Copy link

I am using storybook to develop ui components for react native. Webpack is giving me an error due to react-native-svg

ERROR in ./node_modules/react-native/Libraries/Image/resolveAssetSource.js 18:12
Module parse failed: Unexpected token (18:12)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| const AssetSourceResolver = require('./AssetSourceResolver');
| 
> import type {ResolvedAssetSource} from './AssetSourceResolver';
| 
| let _customSourceTransformer, _serverURL, _scriptURL;
 @ ./node_modules/react-native-svg/lib/module/LocalSvg.js 1:1802-1860
 @ ./node_modules/react-native-svg/lib/module/ReactNativeSVG.js
 @ ./node_modules/react-native-svg/lib/module/index.js

Initially I assumed react-native/Libraries/Image/resolveAssetSource.js was the culprate, but after seeing this I believe the problem is here.

Is there a way for me to fix this or is this actually an invalid import?

react-native-svg/src/LocalSvg.tsx

import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
@JoshLi15
Copy link

Hey, did you find any solution for this issue?

@davisk4rpi
Copy link
Author

Hey, did you find any solution for this issue?

not yet

pratyushok added a commit to pratyushok/react-native-svg that referenced this issue May 26, 2021
@pratyushok
Copy link

pratyushok commented May 26, 2021

You could install it like the following

expo install https://github.com/pratyushok/react-native-svg/releases/download/v12.1.1/react-native-svg-12.1.1.tgz

or

npm install https://github.com/pratyushok/react-native-svg/releases/download/v12.1.1/react-native-svg-12.1.1.tgz

and then don't forget to link it.

@belaziv
Copy link

belaziv commented Dec 30, 2021

any updates? any idea?

@almirfilho
Copy link

any updates? any idea?

@belaziv I've managed to fix mine doing this #1553 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment