cli: Cannot get property 'packageName' on null object
Moving from #537
Environment
System: OS: macOS 10.15 CPU: (4) x64 Intel® Core™ i5-6267U CPU @ 2.90GHz Memory: 2.70 GB / 16.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 12.8.0 - /var/folders/xh/gcxkb1qx2rd3fmqz5vxrs2lh0000gn/T/yarn–1567321836628-0.386672585258681/node Yarn: 1.17.3 - /var/folders/xh/gcxkb1qx2rd3fmqz5vxrs2lh0000gn/T/yarn–1567321836628-0.386672585258681/yarn npm: 6.10.3 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3 Android SDK: API Levels: 28 Build Tools: 28.0.3 IDEs: Android Studio: 3.5 AI-191.8026.42.35.5791312 Xcode: 10.3/10G8 - /usr/bin/xcodebuild
Description
Can’t get react-native 0.61 to work on a monorepo on Android. Build fails with the error: Cannot get property 'packageName' on null object
. iOS works as expected.
Running yarn react-native config
returns this result:
{
"root": "/Users/user/Projects/react-native-web-monorepo",
"reactNativePath": "/Users/user/Projects/react-native-web-monorepo/node_modules/react-native",
"dependencies": {},
"commands": [],
"assets": [],
"platforms": {},
"haste": {
"providesModuleNodeModules": [],
"platforms": []
},
"project": {}
}
Using nohoist
or installing react-native
inside packages/mobile
instead of the root is not an option because that causes a range of other issues.
Reproducible Demo
Branch rn61
with error: https://github.com/brunolemos/react-native-web-monorepo/tree/rn61
Branch master
working, with workarounds: https://github.com/brunolemos/react-native-web-monorepo
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 11
- Comments: 25 (7 by maintainers)
I modify node_modules/@react-native-community/cli-platform-android/native_modules.gradle at line 157 cmdProcess = Runtime.getRuntime().exec(command) change to cmdProcess = Runtime.getRuntime().exec(command,null,new File(System.getProperty(“user.dir”)).getParentFile()) work OK
Having same issue with an example app of a package which contains no native modules.
E: Adding this to react-native.config.js resolved the issue:
@detroit007 The solution is in the last comment by @gaozhaoqun. Thanks @gaozhaoqun Go to the node_modules/@react-native-community/cli-platform-android/native_modules.gradle at line 157 (or find cmdProcess) Is should be something like this:
cmdProcess = Runtime.getRuntime().exec(command)
Change it tocmdProcess = Runtime.getRuntime().exec(command,null,new File(System.getProperty("user.dir")).getParentFile())
I’m also having this problem - @chawlatarika5’s solution is working for me but obviously isn’t ideal.
Some coworkers are able to run the same project with no issues, without editing node_modules. We can’t spot any difference in environment - we’re stumped!
I don’t think it’s a good idea to change any code that is inside node_modules folder. Since it’s added via npm and ignored by git any changes you will make end up staying only on your local.
However, there’s another solution that’s mentioned in one of the recently opened issues. See https://github.com/react-native-community/cli/issues/835#issuecomment-549134018
Basically, add cli-platform-android package to your dev dependencies:
npm install @react-native-community/cli-platform-android --save-dev
This solved my problem and seems safer. @mllw @gaozhaoqun @detroit007 @chawlatarika5 @johnshroff
Successfully upgraded to
react-native@0.61-rc.3
here: https://github.com/brunolemos/react-native-web-monorepo (master)I did have to add react-native dependency to the root package.json and create a react-native.config.js though. Not a big deal but hopefully that get fixed, this workaround was not necessary on <= 0.59.
We have exactly the same problem for 0.60.5. Same project structure setup. We’ve got this error when we set autolinking as it’s described here.
Any idea what to do?
Is it possible to upgrade to react-native 0.61 on a monorepo while this is not fixed? Any older version of
@react-native-community/cli
I can use that would work? I’m holding off upgrading just because of this (still at 0.59).I am still getting this error running react-native 0.63.4
I met the same problem and I got it to work by adding a file
react-native.config.js
to describe my custom android project info. check this document.