Unable to resolve module code-push/script/acquisition-sdk

After build app, the following error appears.

Steps to Reproduce

  1. react-native run-ios

Expected Behavior

No issue happens.

Actual Behavior

  error: Error: Unable to resolve module code-push/script/acquisition-sdk from /Users/guilhermerigotti/Documents/Projects/Work/ecommerce-super-app/node_modules/react-native-code-push/CodePush.js: code-push/script/acquisition-sdk could not be found within the project.

If you are sure the module exists, try these steps:
 1. Clear watchman watches: watchman watch-del-all
 2. Delete node_modules and run yarn install
 3. Reset Metro's cache: yarn start --reset-cache
 4. Remove the cache: rm -rf /tmp/metro-*
> 1 | import { AcquisitionManager as Sdk } from "code-push/script/acquisition-sdk";
    |                                            ^
  2 | import { Alert } from "./AlertAdapter";
  3 | import requestFetchAdapter from "./request-fetch-adapter";
  4 | import { AppState, Platform } from "react-native";
    at ModuleResolver.resolveDependency (/Users/guilhermerigotti/Documents/Projects/Work/ecommerce-super-app/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:191:15)
    at DependencyGraph.resolveDependency (/Users/guilhermerigotti/Documents/Projects/Work/ecommerce-super-app/node_modules/metro/src/node-haste/DependencyGraph.js:353:43)
    at Object.resolve (/Users/guilhermerigotti/Documents/Projects/Work/ecommerce-super-app/node_modules/metro/src/lib/transformHelpers.js:271:42)
    at resolve (/Users/guilhermerigotti/Documents/Projects/Work/ecommerce-super-app/node_modules/metro/src/DeltaBundler/traverseDependencies.js:571:33)
    at /Users/guilhermerigotti/Documents/Projects/Work/ecommerce-super-app/node_modules/metro/src/DeltaBundler/traverseDependencies.js:587:26
    at Array.reduce (<anonymous>)
    at resolveDependencies (/Users/guilhermerigotti/Documents/Projects/Work/ecommerce-super-app/node_modules/metro/src/DeltaBundler/traverseDependencies.js:586:33)
    at /Users/guilhermerigotti/Documents/Projects/Work/ecommerce-super-app/node_modules/metro/src/DeltaBundler/traverseDependencies.js:275:33
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/Users/guilhermerigotti

simulator_screenshot_9CE87FC3-D772-46BC-9407-26DDB680914C

Environment

  • react-native-code-push version: 7.0.0
  • react-native version: 0.63.4
  • iOS/Android/Windows version: iOS 14.4 and Android
  • Does this reproduce on a debug build or release build? both
  • Does this reproduce on a simulator, or only on a physical device? both

7 thoughts on “Unable to resolve module code-push/script/acquisition-sdk

  1. These changes worked for me, I have not tested them in production, only in development as a temporary solution.

    1 – In the node_modules/react-native-code-push/CodePush.js file, change the import path from “code-push/script/acquisition-sdk” to “code-push/src/script acquisition-sdk”.

    2 – In the node_modules/code-push/src/script/acquisition-sdk.ts file

    code

  2. Looks like the issue is caused by the underlying package “code-push” being updated to version 4.0.3 on NPM 7 hours ago, which doesn’t seem to be compatible with the current “react-native-code-push”.

    I added “code-push”: “4.0.2” as a dependency to package.json so that it forces the older 4.0.2 version. Seems to work after you rm -rf node_modules, rm yarn.lock and yarn install again. Remember to remove this when they actually fix things!

    Note: this doesn’t change that “react-native-code-push” still adds “code-push” version 4.0.3 into its own node_modules, just makes version 4.0.2 available in your project’s node_modules

  3. any update on this one? our CI server pull down codes and reset cache, changing the package.json file might only work for developer machine

    Workaround which worked for me is the one shared by @ilyausorov. You can add in your package.json file dependency to package:

    ‘code-push’: ‘4.0.2’

  4. Same problem here using 6.2.1. I’m trying to use version 4.0.2 and yarn says it doesn’t exist.

    you need to add 'code-push': '4.0.2' to your package.json instead of changing the library version to 4.0.2.

  5. Hi guys,
    This is a really big mistake from our side, now we have fixed it and released a new corrected version of code-push v4.0.4. In the future, we will try to be more careful with releases and will test them more closely. Microsoft will continue to support Code-push, there are no plans to deprecate it. Thanks to the community for the quick reaction to the problem, from our side we will check the repositories for critical errors and bugs more often and will fix all vulnerabilities in code-push repos soon.

    Thank you for your understanding and we apologize for the inconvenience.