question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to resolve module `./elements/Shape`

See original GitHub issue

Hi I am getting the following error on android with this below line. Any idea what is the issue?

import Svg, { Path } from ‘react-native-svg’;

Package “react-native-svg”: “^9.9.4”, “react-native”: “0.59.8”,

Error The development server returned response error code: 500

URL: http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false

Body: {“originModulePath”:“/Users/vijdadhi/Public/personal/projects/TCP/code4/packages/mobileapp/node_modules/react-native-svg/src/ReactNativeSVG.ts”,“targetModuleName”:“./elements/Shape”,“message”:“Unable to resolve module ./elements/Shape from /Users/vijdadhi/Public/personal/projects/TCP/code4/packages/mobileapp/node_modules/react-native-svg/src/ReactNativeSVG.ts: The module ./elements/Shape could not be found from /Users/vijdadhi/Public/personal/projects/TCP/code4/packages/mobileapp/node_modules/react-native-svg/src/ReactNativeSVG.ts. Indeed, none of these files exist:\n * /Users/vijdadhi/Public/personal/projects/TCP/code4/packages/mobileapp/node_modules/react-native-svg/src/elements/Shape(.native||.android.jsx|.native.jsx|.jsx|.android.js|.native.js|.js|.android.ts|.native.ts|.ts|.android.json|.native.json|.json)\n * /Users/vijdadhi/Public/personal/projects/TCP/code4/packages/mobileapp/node_modules/react-native-svg/src/elements/Shape/index(.native||.android.jsx|.native.jsx|.jsx|.android.js|.native.js|.js|.android.ts|.native.ts|.ts|.android.json|.native.json|.json)”,“errors”:[{“description”:“Unable to resolve module ./elements/Shape from /Users/vijdadhi/Public/personal/projects/TCP/code4/packages/mobileapp/node_modules/react-native-svg/src/ReactNativeSVG.ts: The module ./elements/Shape could not be found from /Users/vijdadhi/Public/personal/projects/TCP/code4/packages/mobileapp/node_modules/react-native-svg/src/ReactNativeSVG.ts. Indeed, none of these files exist:\n * /Users/vijdadhi/Public/personal/projects/TCP/code4/packages/mobileapp/node_modules/react-native-svg/src/elements/Shape(.native||.android.jsx|.native.jsx|.jsx|.android.js|.native.js|.js|.android.ts|.native.ts|.ts|.android.json|.native.json|.json)\n * /Users/vijdadhi/Public/personal/projects/TCP/code4/packages/mobileapp/node_modules/react-native-svg/src/elements/Shape/index(.native||.android.jsx|.native.jsx|.jsx|.android.js|.native.js|.js|.android.ts|.native.ts|.ts|.android.json|.native.json|.json)”}],“name”:“Error”,“stack”:“Error: Unable to resolve module ./elements/Shape from /Users/vijdadhi/Public/personal/projects/TCP/code4/packages/mobileapp/node_modules/react-native-svg/src/ReactNativeSVG.ts: The module ./elements/Shape could not be found from /Users/vijdadhi/Public/personal/projects/TCP/code4/packages/mobileapp/node_modules/react-native-svg/src/ReactNativeSVG.ts. Indeed, none of these files exist:\n * /Users/vijdadhi/Public/personal/projects/TCP/code4/packages/mobileapp/node_modules/react-native-svg/src/elements/Shape(.native||.android.jsx|.native.jsx|.jsx|.android.js|.native.js|.js|.android.ts|.native.ts|.ts|.android.json|.native.json|.json)\n * /Users/vijdadhi/Public/personal/projects/TCP/code4/packages/mobileapp/node_modules/react-native-svg/src/elements/Shape/index(.native||.android.jsx|.native.jsx|.jsx|.android.js|.native.js|.js|.android.ts|.native.ts|.ts|.android.json|.native.json|.json)\n at ModuleResolver.resolveDependency (/Users/vijdadhi/Public/personal/projects/TCP/code4/packages/mobileapp/node_modules/@react-native-community/cli/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:163:15)\n at ResolutionRequest.resolveDependency (/Users/vijdadhi/Public/personal/projects/TCP/code4/packages/mobileapp/node_modules/@react-native-community/cli/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:52:18)\n at DependencyGraph.resolveDependency (/Users/vijdadhi/Public/personal/projects/TCP/code4/packages/mobileapp/node_modules/@react-native-community/cli/node_modules/metro/src/node-haste/DependencyGraph.js:283:16)\n at Object.resolve (/Users/vijdadhi/Public/personal/projects/TCP/code4/packages/mobileapp/node_modules/@react-native-community/cli/node_modules/metro/src/lib/transformHelpers.js:261:42)\n at /Users/vijdadhi/Public/personal/projects/TCP/code4/packages/mobileapp/node_modules/@react-native-community/cli/node_modules/metro/src/DeltaBundler/traverseDependencies.js:399:31\n at Array.map (<anonymous>)\n at resolveDependencies (/Users/vijdadhi/Public/personal/projects/TCP/code4/packages/mobileapp/node_modules/@react-native-community/cli/node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:18)\n at /Users/vijdadhi/Public/personal/projects/TCP/code4/packages/mobileapp/node_modules/@react-native-community/cli/node_modules/metro/src/DeltaBundler/traverseDependencies.js:269:33\n at Generator.next (<anonymous>)\n at asyncGeneratorStep (/Users/vijdadhi/Public/personal/projects/TCP/code4/packages/mobileapp/node_modules/@react-native-community/cli/node_modules/metro/src/DeltaBundler/traverseDependencies.js:87:24)”} processBundleResult BundleDownloader.java:296 access$200 BundleDownloader.java:37 onResponse BundleDownloader.java:174 execute RealCall.java:206 run NamedRunnable.java:32 runWorker ThreadPoolExecutor.java:1162 run ThreadPoolExecutor.java:636 run Thread.java:764

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

11reactions
Relax594commented, Sep 23, 2019

resolver: { sourceExts: [‘js’, ‘json’, ‘jsx’, ‘ts’, ‘tsx’], },

in your metro.config.js add ‘tsx’ here and it’s working fine again.

3reactions
a4abscommented, Feb 5, 2020

I am getting the same type of issue.

Unable to resolve “./elements/ForeignObject” from “node_modules/react-native-svg/src/ReactNativeSVG.ts”

I’m using expo-CLI to build a react-native app. “react-native-svg”: “9.13.3”

import React from "react";
import {
  Image,
  Platform,
  TextInput,
  ScrollView,
  StyleSheet,
  Text,
  TouchableOpacity,
  View
} from "react-native";

import { Svg, Path, G, Rect } from "react-native-svg";

const SvgComponent = () => {
  return(
   <Svg
                height="100"
                width="100"
                viewBox="40 20 100 40"
                preserveAspectRatio="none">
                <G>
                  <Rect
                    x="0"
                    y="0"
                    width="100"
                    height="100"
                    fill="red"
                  />
                </G>
  </Svg>
}

export default SvgComponent

Is something missing in my implementation?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues - GitHub
Failed building JavaScript bundle. Unable to resolve "./elements/ForeignObject" from "node_modules\react-native-svg\src\ReactNativeSVG.ts"
Read more >
javascript - react-native-svg ForeignObject element not found ...
I've looked through the src files of the node module and can't find any files for the ForeignObject element. Error: Unable to resolve...
Read more >
unable to resolve module assets react native - You.com
1. I had the same problem, I fixed that by below steps: 1-> delete node_modules by: rm -rf node_modules. 2-> delte Pods folder...
Read more >
react-native-svg - npm
Supports most SVG elements and properties (Rect, Circle, Line, Polyline, ... Unable to apply focus point of RadialGradient on Android.
Read more >
"Unable to resolve path to module" while the path exist-Reactjs
Coding example for the question Sublime eslint plugin: "Unable to resolve path to module" while the path exist-Reactjs.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found