Skip to content

when using pnpm, codepush step "react-native bundle" fails #2491

@RanolP

Description

@RanolP

Description

We use pnpm for our rn repo since rn 0.73 stabilized symlink support. It works perfectly for our usecases but when I run appcenter codepush, it fails with the message below:

> appcenter codepush release-react [[REDACTED]]

Running "react-native bundle" command:

node node_modules/.bin/react-native bundle --assets-dest [[SHORTENED]]/CodePush --bundle-output [[SHORTENED]]/CodePush/index.android.bundle --dev false --entry-file index.js --platform android
[[REDACTED]]/node_modules/.bin/react-native:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1178:20)
    at Module._compile (node:internal/modules/cjs/loader:1220:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
    at node:internal/main/run_main_module:23:47

Since pnpm generates node_modules/.bin/react-native executable file as bash script for their own node setup, it cannot be executed simply with node. Here's an example of pnpm-generated bin file:

#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -z "$NODE_PATH" ]; then
  export NODE_PATH="[[REDACTED]]/node_modules/.pnpm/node_modules"
else
  export NODE_PATH="[[REDACTED]]/node_modules/.pnpm/node_modules:$NODE_PATH"
fi
if [ -x "$basedir/node" ]; then
  exec "$basedir/node"  "$basedir/../react-native/cli.js" "$@"
else
  exec node  "$basedir/../react-native/cli.js" "$@"
fi

I think it should be executed without the node specification cuz react-native cli also did shebang very well (you can cat node_modules/react-native/cli.js | head -n1 for check). If there's reason to put node, I'd like to suggest that read the first line of the file for shebang check and branching it to care about to execute with node or not.

Repro Steps

  1. Setup a react-native project with pnpm
  2. Run appcenter codepush with proper arguments

Expected behavior

It should work successfully.

Details

  1. Is there a particular beacon/command that you are having trouble with?
    • appcenter codepush
  2. Which version of the App Center CLI are you using?
    • Uses 2.11.0 but upgrade to 3.0.0 haven't fixed the issue
  3. Which OS version did you experience the issue on?
    • macOS 14 Sonoma
  4. What command line/shell are you using?
    • zsh 5.9 (x86_64-apple-darwin23.0)
  5. What version of Node.js and NPM/Yarn are you using?
    • Node v18.15.0, pnpm 8.15.5 (node version seems irrelevant to this issue)
  6. Additionally, you can provide verbose logs of a CLI command by using DEBUG="appcenter-cli:*" before the command, for example, DEBUG="appcenter-cli:*" appcenter apps list. Include the logs here, don't forget to omit any personal/sensitive data.
    • verbose logs aren't useful this time

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions