facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
116.91k stars 24.05k forks source link

Error: Unable to resolve module ./lib/create-icon-set etc the same kind of error occurs very frequently #34101

Closed burakkbilginn closed 1 year ago

burakkbilginn commented 2 years ago

Description

Whenever I try to install a library in React, this error comes very oftenly. Sometimes it gives the same error even when I import a file from the local storage like "./src/comp". It wasn't giving such errors before, maybe it is because of new version updates or smt else. Also, it doesn't give such errors in react-web-apps, only when doing mobile apps. The last error output after I installed react-native-vector-icons is this:

error: Error: Unable to resolve module ./lib/create-icon-set from C:\Users\SAMSUNG\Desktop\ReactNativeProjects\ProjectName\node_modules\react-native-neat-date-picker\node_modules\react-native-vector-icons\MaterialIcons.js:

None of these files exist:
  * node_modules\react-native-neat-date-picker\node_modules\react-native-vector-icons\lib\create-icon-set(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
  * node_modules\react-native-neat-date-picker\node_modules\react-native-vector-icons\lib\create-icon-set\index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
  4 |  */
  5 |
> 6 | import createIconSet from './lib/create-icon-set';
    |                            ^
  7 | import glyphMap from './glyphmaps/MaterialIcons.json';
  8 |
  9 | const iconSet = createIconSet(glyphMap, 'Material Icons', 'MaterialIcons.ttf');
    at ModuleResolver.resolveDependency (C:\Users\SAMSUNG\Desktop\ReactNativeProjects\ProjectName\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:136:15)
    at DependencyGraph.resolveDependency (C:\Users\SAMSUNG\Desktop\ReactNativeProjects\ProjectName\node_modules\metro\src\node-haste\DependencyGraph.js:231:43)
    at Object.resolve (C:\Users\SAMSUNG\Desktop\ReactNativeProjects\ProjectName\node_modules\metro\src\lib\transformHelpers.js:129:24)
    at resolve (C:\Users\SAMSUNG\Desktop\ReactNativeProjects\ProjectName\node_modules\metro\src\DeltaBundler\traverseDependencies.js:396:33)
    at C:\Users\SAMSUNG\Desktop\ReactNativeProjects\ProjectName\node_modules\metro\src\DeltaBundler\traverseDependencies.js:412:26
    at Array.reduce (<anonymous>)
    at resolveDependencies (C:\Users\SAMSUNG\Desktop\ReactNativeProjects\ProjectName\node_modules\metro\src\DeltaBundler\traverseDependencies.js:411:33)
    at processModule (C:\Users\SAMSUNG\Desktop\ReactNativeProjects\ProjectName\node_modules\metro\src\DeltaBundler\traverseDependencies.js:140:31)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async addDependency (C:\Users\SAMSUNG\Desktop\ReactNativeProjects\ProjectName\node_modules\metro\src\DeltaBundler\traverseDependencies.js:230:18)

As can be seen, I guess it doesn't find the files inside most of the import statements(there is an arrow under the dot).

This is another error output:

error: Error: Unable to resolve module ./Libraries/Utilities/warnOnce from C:\Users\SAMSUNG\Desktop\ReactNativeProjects\ProjectName\node_modules\react-native\index.js:

None of these files exist:
  * node_modules\react-native\Libraries\Utilities\warnOnce(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
  * node_modules\react-native\Libraries\Utilities\warnOnce\index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
  102 |
  103 | const invariant = require('invariant');
> 104 | const warnOnce = require('./Libraries/Utilities/warnOnce');
      |                           ^
  105 |
  106 | module.exports = {
  107 |   // Components
    at ModuleResolver.resolveDependency (C:\Users\SAMSUNG\Desktop\ReactNativeProjects\ProjectName\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:136:15)
    at DependencyGraph.resolveDependency (C:\Users\SAMSUNG\Desktop\ReactNativeProjects\ProjectName\node_modules\metro\src\node-haste\DependencyGraph.js:231:43)
    at Object.resolve (C:\Users\SAMSUNG\Desktop\ReactNativeProjects\ProjectName\node_modules\metro\src\lib\transformHelpers.js:129:24)
    at resolve (C:\Users\SAMSUNG\Desktop\ReactNativeProjects\ProjectName\node_modules\metro\src\DeltaBundler\traverseDependencies.js:396:33)
    at C:\Users\SAMSUNG\Desktop\ReactNativeProjects\ProjectName\node_modules\metro\src\DeltaBundler\traverseDependencies.js:412:26
    at Array.reduce (<anonymous>)
    at resolveDependencies (C:\Users\SAMSUNG\Desktop\ReactNativeProjects\ProjectName\node_modules\metro\src\DeltaBundler\traverseDependencies.js:411:33)
    at processModule (C:\Users\SAMSUNG\Desktop\ReactNativeProjects\ProjectName\node_modules\metro\src\DeltaBundler\traverseDependencies.js:140:31)
    at async addDependency (C:\Users\SAMSUNG\Desktop\ReactNativeProjects\ProjectName\node_modules\metro\src\DeltaBundler\traverseDependencies.js:230:18)
    at async Promise.all (index 0)

What should I do?

Version

0.69

Output of npx react-native info

System: OS: Windows 10 10.0.19041 CPU: (4) x64 Intel(R) Core(TM) i5-3317U CPU @ 1.70GHz Memory: 3.14 GB / 11.79 GB Binaries: Node: 16.15.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.18 - ~\AppData\Roaming\npm\yarn.CMD npm: 8.13.1 - C:\Program Files\nodejs\npm.CMD Watchman: 20220320.140531.0 - C:\ProgramData\chocolatey\bin\watchman.EXE SDKs: Android SDK: Android NDK: 22.1.7171670 Windows SDK: Not Found IDEs: Android Studio: Version 2021.1.0.0 AI-211.7628.21.2111.8139111 Visual Studio: Not Found Languages: Java: 11.0.14.1 - C:\Program Files\OpenJDK\openjdk-11.0.14.1_1\bin\javac.EXE npmPackages: @react-native-community/cli: Not Found react: 18.2.0 => 18.2.0 react-native: 0.69.1 => 0.69.1 react-native-windows: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

Even when I create projects by react-native init anyProject such unresolved module errors come. Also I cannot create mobile project without adding the version spesificly, I mean like this : "react-native init ProjectName --version 0.68.2" Is it a bug? Or am I doing something wrong?

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

import React, { useState } from 'react';
import type {Node} from 'react';
import {
  StyleSheet,
  View,
} from 'react-native';

import DatePicker from 'react-native-neat-date-picker';
import Calendar from './src/components/Calendar';

const App: () => Node = () => {

  return (
    <View>
      <Calendar />
    </View>
  );
};

const styles = StyleSheet.create({
  sectionContainer: {
    marginTop: 32,
    paddingHorizontal: 24,
  },
  sectionTitle: {
    fontSize: 24,
    fontWeight: '600',
  },
  sectionDescription: {
    marginTop: 8,
    fontSize: 18,
    fontWeight: '400',
  },
  highlight: {
    fontWeight: '700',
  },
});

export default App;
cortinico commented 1 year ago

The last error output after I installed react-native-vector-icons is this:

Have you tried opening this issue against react-native-vector-icons?

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 7 days with no activity.