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

0.62.1. error: Error: Unable to resolve module react-native/Libraries/vendor/core/isEmpty from node_modules/deprecated-react-native-listview/index.js: react-native/Libraries/vendor/core/isEmpty could not be found within the project. #28546

Closed
studass opened this issue Apr 6, 2020 · 14 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@studass
Copy link

studass commented Apr 6, 2020

Upgraded project to 0.62.1.
Deleted node_modules, watchman, metro cache etc.
Build completes but application fails to start with the error:

error: Error: Unable to resolve module react-native/Libraries/vendor/core/isEmpty from node_modules/deprecated-react-native-listview/index.js: react-native/Libraries/vendor/core/isEmpty could not be found within the project.

Description

Please provide a clear and concise description of what the bug is. Include screenshots if needed.
Please test using the latest React Native release to make sure your issue has not already been fixed: https://reactnative.dev/docs/upgrading.html

React Native version:

System:
OS: macOS 10.15.4
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 2.35 GB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.16.1 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.9.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK: Not Found
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6308749
Xcode: 11.4/11E146 - /usr/bin/xcodebuild
Languages:
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.8.6 => 16.8.6
react-native: ^0.62.1 => 0.62.1
npmGlobalPackages:
react-native: Not Found

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. Clear watchman watches: watchman watch-del-all
  2. Delete node_modules: rm -rf node_modules and run yarn install
  3. Reset Metro's cache: yarn start --reset-cache
  4. Remove the cache: rm -rf /tmp/metro-*
@radko93
Copy link
Contributor

radko93 commented Apr 7, 2020

Do you have any code to reproduce this?

@kakakalot
Copy link

I think this issue come from dependencies.
Likes sohobloo/react-native-modal-dropdown#245

@onebigdoor
Copy link

i took out react-native-modal-dropdown and the error went away.

@hramos
Copy link
Contributor

hramos commented Apr 7, 2020

Since this is an issue about upgrading to a newer version of React Native, I recommend making use of the new upgrade support forum: https://github.com/react-native-community/upgrade-support

@hramos hramos closed this as completed Apr 7, 2020
@raza-repo
Copy link

yeah, it is the react-native-modal-dropdown problem. Remove it and solve it

@studass
Copy link
Author

studass commented Apr 8, 2020

Yeah the removal of react-native-modal-dropdown worked 👍🏻 thanks for the help.

@tomhagen
Copy link

I think this issue come from dependencies.
Likes sohobloo/react-native-modal-dropdown#245

Exactly where the errors come from. Btw, is there any way to use react-native-modal-dropdown ?

@kakakalot
Copy link

I think this issue come from dependencies.
Likes sohobloo/react-native-modal-dropdown#245

Exactly where the errors come from. Btw, is there any way to use react-native-modal-dropdown ?

you can copy its source code, just one js file, then replace ListView with FlatList. That is all my work.
Or you can use my edited ModalDropdown here
https://github.com/kakakalot/open-code/blob/master/ModalDropdown.js

@anhdevit
Copy link

I think this issue come from dependencies.
Likes sohobloo/react-native-modal-dropdown#245

Exactly where the errors come from. Btw, is there any way to use react-native-modal-dropdown ?

you can copy its source code, just one js file, then replace ListView with FlatList. That is all my work.
Or you can use my edited ModalDropdown here
https://github.com/kakakalot/open-code/blob/master/ModalDropdown.js

it worked

@export-mike
Copy link

for those that might be interested I just patched this package with isEmpty and merge from react native core which has now been deleted

add the file to patches/deprecated-react-native-listview+0.0.5.patch and install and configure patch-package

diff --git a/node_modules/deprecated-react-native-listview/ListViewDataSource.js b/node_modules/deprecated-react-native-listview/ListViewDataSource.js
index 7cf065a..2d7aea4 100644
--- a/node_modules/deprecated-react-native-listview/ListViewDataSource.js
+++ b/node_modules/deprecated-react-native-listview/ListViewDataSource.js
@@ -10,7 +10,20 @@
 'use strict';
 
 const invariant = require('invariant');
-const isEmpty = require('react-native/Libraries/vendor/core/isEmpty');
+
+
+function isEmpty(obj: mixed): boolean {
+  if (Array.isArray(obj)) {
+    return obj.length === 0;
+  } else if (typeof obj === 'object') {
+    for (const i in obj) {
+      return false;
+    }
+    return true;
+  } else {
+    return !obj;
+  }
+}
 /* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
  * found when Flow v0.54 was deployed. To see the error delete this comment and
  * run Flow. */
diff --git a/node_modules/deprecated-react-native-listview/index.js b/node_modules/deprecated-react-native-listview/index.js
index 4654972..f090439 100644
--- a/node_modules/deprecated-react-native-listview/index.js
+++ b/node_modules/deprecated-react-native-listview/index.js
@@ -21,9 +21,179 @@ const StaticRenderer = require('./StaticRenderer');
 const View = ReactNative.View;
 const cloneReferencedElement = require('react-clone-referenced-element');
 const createReactClass = require('create-react-class');
-const isEmpty = require('react-native/Libraries/vendor/core/isEmpty');
-const merge = require('react-native/Libraries/vendor/core/merge');
 
+
+const invariant = require('invariant');
+
+/**
+ * Maximum number of levels to traverse. Will catch circular structures.
+ * @const
+ */
+const MAX_MERGE_DEPTH = 36;
+
+/**
+ * We won't worry about edge cases like new String('x') or new Boolean(true).
+ * Functions and Dates are considered terminals, and arrays are not.
+ * @param {*} o The item/object/value to test.
+ * @return {boolean} true iff the argument is a terminal.
+ */
+const isTerminal = function (o) {
+  return typeof o !== 'object' || o instanceof Date || o === null;
+};
+
+const mergeHelpers = {
+  MAX_MERGE_DEPTH: MAX_MERGE_DEPTH,
+
+  isTerminal: isTerminal,
+
+  /**
+   * Converts null/undefined values into empty object.
+   *
+   * @param {?Object=} arg Argument to be normalized (nullable optional)
+   * @return {!Object}
+   */
+  normalizeMergeArg: function (arg) {
+    return arg === undefined || arg === null ? {} : arg;
+  },
+
+  /**
+   * If merging Arrays, a merge strategy *must* be supplied. If not, it is
+   * likely the caller's fault. If this function is ever called with anything
+   * but `one` and `two` being `Array`s, it is the fault of the merge utilities.
+   *
+   * @param {*} one Array to merge into.
+   * @param {*} two Array to merge from.
+   */
+  checkMergeArrayArgs: function (one, two) {
+    invariant(
+      Array.isArray(one) && Array.isArray(two),
+      'Tried to merge arrays, instead got %s and %s.',
+      one,
+      two,
+    );
+  },
+
+  /**
+   * @param {*} one Object to merge into.
+   * @param {*} two Object to merge from.
+   */
+  checkMergeObjectArgs: function (one, two) {
+    mergeHelpers.checkMergeObjectArg(one);
+    mergeHelpers.checkMergeObjectArg(two);
+  },
+
+  /**
+   * @param {*} arg
+   */
+  checkMergeObjectArg: function (arg) {
+    invariant(
+      !isTerminal(arg) && !Array.isArray(arg),
+      'Tried to merge an object, instead got %s.',
+      arg,
+    );
+  },
+
+  /**
+   * @param {*} arg
+   */
+  checkMergeIntoObjectArg: function (arg) {
+    invariant(
+      (!isTerminal(arg) || typeof arg === 'function') && !Array.isArray(arg),
+      'Tried to merge into an object, instead got %s.',
+      arg,
+    );
+  },
+
+  /**
+   * Checks that a merge was not given a circular object or an object that had
+   * too great of depth.
+   *
+   * @param {number} Level of recursion to validate against maximum.
+   */
+  checkMergeLevel: function (level) {
+    invariant(
+      level < MAX_MERGE_DEPTH,
+      'Maximum deep merge depth exceeded. You may be attempting to merge ' +
+      'circular structures in an unsupported way.',
+    );
+  },
+
+  /**
+   * Checks that the supplied merge strategy is valid.
+   *
+   * @param {string} Array merge strategy.
+   */
+  checkArrayStrategy: function (strategy) {
+    invariant(
+      strategy === undefined || strategy in mergeHelpers.ArrayStrategies,
+      'You must provide an array strategy to deep merge functions to ' +
+      'instruct the deep merge how to resolve merging two arrays.',
+    );
+  },
+
+  /**
+   * Set of possible behaviors of merge algorithms when encountering two Arrays
+   * that must be merged together.
+   * - `clobber`: The left `Array` is ignored.
+   * - `indexByIndex`: The result is achieved by recursively deep merging at
+   *   each index. (not yet supported.)
+   */
+  ArrayStrategies: {
+    Clobber: 'Clobber',
+    Concat: 'Concat',
+    IndexByIndex: 'IndexByIndex',
+  },
+};
+
+
+
+var checkMergeObjectArg = mergeHelpers.checkMergeObjectArg;
+var checkMergeIntoObjectArg = mergeHelpers.checkMergeIntoObjectArg;
+
+/**
+ * Shallow merges two structures by mutating the first parameter.
+ *
+ * @param {object|function} one Object to be merged into.
+ * @param {?object} two Optional object with properties to merge from.
+ */
+function mergeInto(one, two) {
+  checkMergeIntoObjectArg(one);
+  if (two != null) {
+    checkMergeObjectArg(two);
+    for (var key in two) {
+      if (!Object.prototype.hasOwnProperty.call(two, key)) {
+        continue;
+      }
+      one[key] = two[key];
+    }
+  }
+}
+
+/**
+ * Shallow merges two structures into a return value, without mutating either.
+ *
+ * @param {?object} one Optional object with properties to merge from.
+ * @param {?object} two Optional object with properties to merge from.
+ * @return {object} The shallow extension of one by two.
+ */
+const merge = function (one, two) {
+  const result = {};
+  mergeInto(result, one);
+  mergeInto(result, two);
+  return result;
+};
+function isEmpty(obj: mixed): boolean {
+  if (Array.isArray(obj)) {
+    return obj.length === 0;
+  } else if (typeof obj === 'object') {
+    for (const i in obj) {
+      return false;
+    }
+    return true;
+  } else {
+    return !obj;
+  }
+}
 import type {Props as ScrollViewProps} from 'react-native/Libraries/Components/ScrollView/ScrollView';
 
 const DEFAULT_PAGE_SIZE = 1;

@superdopey
Copy link

Thx @export-mike! Your patch works like a charm.

@Muhammad-Wasi
Copy link

You can fix it in package.json.

{
"dependencies": {
"react-native-modal-dropdown": "0.6.2"
}
}

@speeeechless
Copy link

You can fix it in package.json.

{
"dependencies": {
"react-native-modal-dropdown": "0.6.2"
}
}

Dude... I was facing this problem right now, and your answer works perfectly! 7 minutes earlier and I will have never see your answer ^^'

@dhavalpanchani
Copy link

You can fix it in package.json.

{
"dependencies": {
"react-native-modal-dropdown": "0.6.2"
}
}

this worked for me!

@facebook facebook locked as resolved and limited conversation to collaborators Oct 1, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 1, 2021
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