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

Unable to resolve module missing-asset-registry-path #38282

Closed
MajidAziz3 opened this issue Jul 11, 2023 · 23 comments
Closed

Unable to resolve module missing-asset-registry-path #38282

MajidAziz3 opened this issue Jul 11, 2023 · 23 comments
Labels
📦Bundler Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue.

Comments

@MajidAziz3
Copy link

Description

error Unable to resolve module missing-asset-registry-path from path/src/assets/image.png: missing-asset-registry-path could not be found within the project or in these directories:
node_modules

1 | �PNG
2 |
3 |
4 | IHDRX^;I�sRGB���@IDATx�] |E֯���$܇�C<�UBeUTċ@D/�k=�UDv�o��..
Error: Unable to resolve module missing-asset-registry-path from path/src/assets/image.png: missing-asset-registry-path could not be found within the project or in these directories:

React Native Version

0.72.1

Output of npx react-native info

System:
OS: macOS 13.4
CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Memory: 52.41 MB / 8.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.2.0
path: /usr/local/bin/node
Yarn:
version: 1.22.19
path: /usr/local/bin/yarn
npm:
version: 9.6.6
path: /usr/local/bin/npm
Watchman:
version: 2023.05.22.00
path: /usr/local/bin/watchman
Managers:
CocoaPods:
version: 1.12.1
path: /Users/apple/.rubies/ruby-3.2.2/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 22.4
- iOS 16.4
- macOS 13.3
- tvOS 16.4
- watchOS 9.4
Android SDK: Not Found
IDEs:
Android Studio: 2022.2 AI-222.4459.24.2221.9971841
Xcode:
version: 14.3.1/14E300c
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.7
path: /usr/bin/javac
Ruby:
version: 3.2.2
path: /Users/apple/.rubies/ruby-3.2.2/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 11.3.5
wanted: ^11.3.5
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.72.1
wanted: 0.72.1
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false

Steps to reproduce

Error coming while running Apk bundling commands npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

Snack, code example, screenshot, or link to a repository

command for bundling assets: npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

@blakef
Copy link
Contributor

blakef commented Jul 11, 2023

Hi, we're going to need a bit more information to be helpful. Here are some things you can do in the interim to unblock yourself:

If you think this is a more general issue and not specific to your setup, can you provide a minimum reproducible example?

@blakef blakef added Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. and removed Needs: Triage 🔍 labels Jul 11, 2023
@github-actions
Copy link

⚠️ Missing Reproducible Example
ℹ️ It looks like your issue is missing a reproducible example. Please provide either:

@MajidAziz3
Copy link
Author

MajidAziz3 commented Jul 11, 2023

@blakef the project is too old , i am sure the issue is an metro.config , here is the config file , please have a look ,the issue is only with png images

module.exports = (async () => {
 const {
   resolver: { sourceExts, assetExts },
 } = await getDefaultConfig();

 return {
   transformer: {
     babelTransformerPath: require.resolve('react-native-svg-transformer'),
     getTransformOptions: async () => ({
       transform: {
         experimentalImportSupport: false,
         inlineRequires: false,
       },
     }),
   },
   resolver: {
     assetExts: assetExts.filter(ext => ext !== 'svg'),
     sourceExts: [...sourceExts, 'svg'],
   },
 };
})();

react-native Config File

module.exports = {
  project: {
    ios: {},
    android: {}, // grouped into "project"
  },
  assets: ["./src/assets/fonts/"], // stays the same
};

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Jul 11, 2023
@cortinico
Copy link
Contributor

Potentially related to react-navigation/react-navigation#11192

@MajidAziz3 without a repro we can't really help further.

@cortinico cortinico added Needs: Author Feedback and removed Needs: Attention Issues where the author has responded to feedback. labels Jul 11, 2023
@huntie
Copy link
Member

huntie commented Jul 11, 2023

@MajidAziz3 Your metro.config.js is in an incorrect format, please adapt to match the example here: facebook/metro#1028 (comment)

@huntie
Copy link
Member

huntie commented Jul 11, 2023

Duplicate of facebook/metro#1028.

@huntie huntie closed this as completed Jul 11, 2023
@KushalDesai1
Copy link

I had to downgrade react-native version from 0.73 to 0.68.

And node version from v20 to v16.20.0.

@Leslie-Wong-H
Copy link

I am facing this with jpg, yet png is fine.
react-native 0.72.8

@Leslie-Wong-H
Copy link

I am facing this with jpg, yet png is fine. react-native 0.72.8

This config works.

/**
 * Metro configuration for React Native
 * https://github.com/facebook/react-native
 *
 * @format
 */

const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');

const defaultConfig = getDefaultConfig(__dirname);

const {
  resolver: { sourceExts, assetExts },
} = getDefaultConfig(__dirname);

const config = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: true,
      },
    }),
    babelTransformerPath: require.resolve('react-native-svg-transformer'),
  },
  resolver: {
    assetExts: assetExts.filter(ext => ext !== 'svg'),
    sourceExts: [...sourceExts, 'svg'],
  },
};

module.exports = mergeConfig(defaultConfig, config);

@leorodriguesdev
Copy link

@Leslie-Wong-H thank you, you saved me

@santiagoquintero95
Copy link

I am facing this with jpg, yet png is fine. react-native 0.72.8

This config works.

/**
 * Metro configuration for React Native
 * https://github.com/facebook/react-native
 *
 * @format
 */

const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');

const defaultConfig = getDefaultConfig(__dirname);

const {
  resolver: { sourceExts, assetExts },
} = getDefaultConfig(__dirname);

const config = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: true,
      },
    }),
    babelTransformerPath: require.resolve('react-native-svg-transformer'),
  },
  resolver: {
    assetExts: assetExts.filter(ext => ext !== 'svg'),
    sourceExts: [...sourceExts, 'svg'],
  },
};

module.exports = mergeConfig(defaultConfig, config);

Omg finally it works. I was using an old config and I moved to react native 7.3.0 and this update is required or the archive will fail

@zhairui
Copy link

zhairui commented Jan 25, 2024

I meet an error , pls help . thanks ! here is the error stack:

[TypeError: _$$_REQUIRE(_dependencyMap[7], "(...)ssets-registry/path-support.js") is not a function (it is Object)] {"componentStack": "
in BaseImage (created by ImageBackground)
in RCTView (created by View)
in View (created by ImageBackground)
....

@ShivBhanKushWaha
Copy link

error: Error: Unable to resolve module missing-asset-registry-path from D:\Hoverin Aerospace\HoverinApp\node_modules\react-native\Libraries\LogBox\UI\LogBoxImages\close.png: missing-asset-registry-path could not be found within the project or in these directories:
node_modules\react-native\node_modules
node_modules

1 | �PNG
2 | →
3 |
4 | IHDR∟♦�♦↨▼�IDATxڝՅ
at ModuleResolver.resolveDependency (D:\Hoverin Aerospace\HoverinApp\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:153:15)
at DependencyGraph.resolveDependency (D:\Hoverin Aerospace\HoverinApp\node_modules\metro\src\node-haste\DependencyGraph.js:271:43)
at D:\Hoverin Aerospace\HoverinApp\node_modules\metro\src\lib\transformHelpers.js:176:21
at resolveDependencies (D:\Hoverin Aerospace\HoverinApp\node_modules\metro\src\DeltaBundler\buildSubgraph.js:56:25)
at visit (D:\Hoverin Aerospace\HoverinApp\node_modules\metro\src\DeltaBundler\buildSubgraph.js:107:30)
at async Promise.all (index 12)
at async visit (D:\Hoverin Aerospace\HoverinApp\node_modules\metro\src\DeltaBundler\buildSubgraph.js:116:5)
at async Promise.all (index 5)
at async visit (D:\Hoverin Aerospace\HoverinApp\node_modules\metro\src\DeltaBundler\buildSubgraph.js:116:5)
at async Promise.all (index 15)
how to fix this issue

@alexdarh
Copy link

error: Error: Unable to resolve module missing-asset-registry-path from D:\Hoverin Aerospace\HoverinApp\node_modules\react-native\Libraries\LogBox\UI\LogBoxImages\close.png: missing-asset-registry-path could not be found within the project or in these directories: node_modules\react-native\node_modules node_modules

1 | �PNG
2 | →
3 |
4 | IHDR∟♦�♦↨▼�IDATxڝՅ
at ModuleResolver.resolveDependency (D:\Hoverin Aerospace\HoverinApp\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:153:15)
at DependencyGraph.resolveDependency (D:\Hoverin Aerospace\HoverinApp\node_modules\metro\src\node-haste\DependencyGraph.js:271:43)
at D:\Hoverin Aerospace\HoverinApp\node_modules\metro\src\lib\transformHelpers.js:176:21
at resolveDependencies (D:\Hoverin Aerospace\HoverinApp\node_modules\metro\src\DeltaBundler\buildSubgraph.js:56:25)
at visit (D:\Hoverin Aerospace\HoverinApp\node_modules\metro\src\DeltaBundler\buildSubgraph.js:107:30)
at async Promise.all (index 12)
at async visit (D:\Hoverin Aerospace\HoverinApp\node_modules\metro\src\DeltaBundler\buildSubgraph.js:116:5)
at async Promise.all (index 5)
at async visit (D:\Hoverin Aerospace\HoverinApp\node_modules\metro\src\DeltaBundler\buildSubgraph.js:116:5)
at async Promise.all (index 15)
how to fix this issue
same error

@PavelVisme
Copy link

PavelVisme commented Feb 14, 2024

same error after upgrading to expo50

Unable to resolve "missing-asset-registry-path" from "../../node_modules/.pnpm/react-native@0.73.4_@babel+core@7.23.3_@babel+preset-env@7.23.3_react@18.2.0/node_modules/react-native/Libraries/LogBox/UI/LogBoxImages/close.png"

This is example with almost empty index.js file

@DeabitTech
Copy link

but why there are a lot of issues about the upgrading of expo 50? @expo please fix it

@uoon-dev
Copy link

(Expo SDK 50) Every solution didn't work for me, but I solved missing-asset-registry-path issue by below custom metro config.

// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require('expo/metro-config');

/** @type {import('expo/metro-config').MetroConfig} */
const config = getDefaultConfig(__dirname);

config.transformer = {
  ...config.transformer,
  babelTransformerPath: require.resolve('react-native-svg-transformer'),
  assetPlugins: ['expo-asset/tools/hashAssetFiles'],
  getTransformOptions: async () => ({
    transform: {
      experimentalImportSupport: false,
      inlineRequires: true,
    },
  }),
};
//
config.resolver = {
  ...config.resolver,
  assetExts: config.resolver.assetExts.filter((ext) => ext !== 'svg'),
  sourceExts: [...config.resolver.sourceExts, 'svg', 'd.ts'],
};

module.exports = config;

@Tusharatha7
Copy link

with png. none of the above metroconfig is working for. what can i do?

Unable to resolve "./assets/logo.png" from "screens\Startscreen.js"

@ch3njust1n
Copy link

(Expo SDK 50) Every solution didn't work for me, but I solved missing-asset-registry-path issue by below custom metro config.

// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require('expo/metro-config');

/** @type {import('expo/metro-config').MetroConfig} */
const config = getDefaultConfig(__dirname);

config.transformer = {
  ...config.transformer,
  babelTransformerPath: require.resolve('react-native-svg-transformer'),
  assetPlugins: ['expo-asset/tools/hashAssetFiles'],
  getTransformOptions: async () => ({
    transform: {
      experimentalImportSupport: false,
      inlineRequires: true,
    },
  }),
};
//
config.resolver = {
  ...config.resolver,
  assetExts: config.resolver.assetExts.filter((ext) => ext !== 'svg'),
  sourceExts: [...config.resolver.sourceExts, 'svg', 'd.ts'],
};

module.exports = config;

This worked for me! Thank you!

@KStockton
Copy link

(Expo SDK 50) Every solution didn't work for me, but I solved missing-asset-registry-path issue by below custom metro config.

// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require('expo/metro-config');

/** @type {import('expo/metro-config').MetroConfig} */
const config = getDefaultConfig(__dirname);

config.transformer = {
  ...config.transformer,
  babelTransformerPath: require.resolve('react-native-svg-transformer'),
  assetPlugins: ['expo-asset/tools/hashAssetFiles'],
  getTransformOptions: async () => ({
    transform: {
      experimentalImportSupport: false,
      inlineRequires: true,
    },
  }),
};
//
config.resolver = {
  ...config.resolver,
  assetExts: config.resolver.assetExts.filter((ext) => ext !== 'svg'),
  sourceExts: [...config.resolver.sourceExts, 'svg', 'd.ts'],
};

module.exports = config;

This worked for me! Thank you!

This worked for me as well.

@haidernayyar
Copy link

I am facing this with jpg, yet png is fine. react-native 0.72.8

This config works.

/**
 * Metro configuration for React Native
 * https://github.com/facebook/react-native
 *
 * @format
 */

const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');

const defaultConfig = getDefaultConfig(__dirname);

const {
  resolver: { sourceExts, assetExts },
} = getDefaultConfig(__dirname);

const config = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: true,
      },
    }),
    babelTransformerPath: require.resolve('react-native-svg-transformer'),
  },
  resolver: {
    assetExts: assetExts.filter(ext => ext !== 'svg'),
    sourceExts: [...sourceExts, 'svg'],
  },
};

module.exports = mergeConfig(defaultConfig, config);

This worked for me and remember to re-start the metro

@quotentiroler
Copy link

I cannot get over this issue for png files after updating to expo sdk 51 :(

@meshboy88
Copy link

(Expo SDK 50) Every solution didn't work for me, but I solved missing-asset-registry-path issue by below custom metro config.

// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require('expo/metro-config');

/** @type {import('expo/metro-config').MetroConfig} */
const config = getDefaultConfig(__dirname);

config.transformer = {
  ...config.transformer,
  babelTransformerPath: require.resolve('react-native-svg-transformer'),
  assetPlugins: ['expo-asset/tools/hashAssetFiles'],
  getTransformOptions: async () => ({
    transform: {
      experimentalImportSupport: false,
      inlineRequires: true,
    },
  }),
};
//
config.resolver = {
  ...config.resolver,
  assetExts: config.resolver.assetExts.filter((ext) => ext !== 'svg'),
  sourceExts: [...config.resolver.sourceExts, 'svg', 'd.ts'],
};

module.exports = config;

Bro, you made my day. Thanks, it worked for the png issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦Bundler Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue.
Projects
None yet
Development

No branches or pull requests