cli icon indicating copy to clipboard operation
cli copied to clipboard

Unable to do pod install. Throwing error use_native_modules!

Open Balasnest opened this issue 4 years ago • 13 comments

Environment

I am upgrading two react native project from 0.59.10 to 0.63.2. The project A was successfully upgraded. But facing a problem with the project B (only for ios. Android is working). when I try to do pod install it's throwing an error. I just went back to the project A, cleaned all, and did pod install it still working. Not sure why its causing a problem with the project B.

pod version: tried with 1.10.0 and 1.7.5

Description:

Log:

Node modules has this path @react-native-community/cli-platform-ios/native_modules

pod install --verbose
  $ /usr/local/bin/node -e try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}
  undefined
internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '/Users/bala/Documents/projectName/ios/undefined'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

[!] Invalid `Podfile` file: 784: unexpected token at ''.

 #  from /Users/bala/Documents/projectName/ios/Podfile:15
 #  -------------------------------------------
 #
 >    config = use_native_modules!
 #
 #  -------------------------------------------

/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.10.0/lib/cocoapods-core/podfile.rb:318:in `rescue in block in from_ruby'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.10.0/lib/cocoapods-core/podfile.rb:312:in `block in from_ruby'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.10.0/lib/cocoapods-core/podfile.rb:50:in `instance_eval'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.10.0/lib/cocoapods-core/podfile.rb:50:in `initialize'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.10.0/lib/cocoapods-core/podfile.rb:310:in `new'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.10.0/lib/cocoapods-core/podfile.rb:310:in `from_ruby'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.10.0/lib/cocoapods-core/podfile.rb:276:in `from_file'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/config.rb:205:in `podfile'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/command.rb:160:in `verify_podfile_exists!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/command/install.rb:46:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'

package.json

Just to verify I have removed all dependencies from package.json, kept only react and react native, and tried pod install. Still same error.

"dependencies": {
    "react": "16.13.1",
    "react-native": "0.63.2"
  },
  "devDependencies": {}

podfile:

require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '11.0'

target 'projectName' do

  # Pods for projectName
  pod 'Firebase/Core', '~> 4.13.0'
  pod 'Firebase/Messaging'
  pod 'TwilioVideo', '~> 3.2.3'
  pod 'AppsFlyerFramework'

  config = use_native_modules!
  use_react_native!(:path => config["reactNativePath"])

end

Balasnest avatar Nov 03 '20 05:11 Balasnest

Did you try this tool?

React Native Upgrade Helper

chakrihacker avatar Nov 03 '20 05:11 chakrihacker

Yes. @chakrihacker I followed the same on both projects.

Balasnest avatar Nov 03 '20 05:11 Balasnest

@chakrihacker I am also facing the same issue. Any help will be appreciated. Thanks

rishab1065 avatar Nov 03 '20 06:11 rishab1065

Try this

add the following line in the beginning

require_relative '../node_modules/react-native/scripts/react_native_pods'

and remove pods you added and check

chakrihacker avatar Nov 03 '20 12:11 chakrihacker

I have same issue,how to fix ?

lengqingfeng avatar Nov 12 '20 06:11 lengqingfeng

What's the output of running react-native config command from ios directory or from root?

thymikee avatar Nov 26 '20 16:11 thymikee

What's the output of running react-native config command from ios directory or from root?

In iOS folder

Command `config` unrecognized. Make sure that you have run `npm install` and that you are inside a react-native project.

In project root

(node:63080) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)

EDIT:

This is happening going from 0.60.6 to 0.62.0, btw. For some reason my react-native-cli seems to come back as 2.0.1 for some reason.

pod --version
1.10.0

EDIT:

ruby --version
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin18]

OKNoah avatar Dec 09 '20 12:12 OKNoah

I'm having the same error, but only when running trough CI. If I remote access the CI machine, and run there locally, it works fine.

evertoncunha avatar Dec 09 '20 13:12 evertoncunha

I found the solution in my case:

It may be that my react-native CLI was globally installed and out of date due to package manager changes. However, once I fixed this by deleting yarn's version and installing with pnpm, the problem persisted and doing react-native --version gave an error about my config. I had also tried to run npx react-native-macos-init more than once but had it fail because of one package manager or another bring broken or uninstalled. This left my react-native.config.js with multiple lines of code containing:

const macSwitch = '--use-react-native-macos'

if (process.argv.includes(macSwitch)) {
  process.argv = process.argv.filter((arg) => arg !== macSwitch)
  process.argv.push('--config=metro.config.macos.js')
  module.exports = {
    reactNativePath: 'node_modules/react-native-macos',
  }
}

Deleting all but one allowed me to go back and run pod install without issues.

OKNoah avatar Dec 09 '20 21:12 OKNoah

Hi any update i still have this issue when using rn 0.64.2

ah584d avatar Aug 03 '21 18:08 ah584d

I ran into this issue as well. In my case, I had unzipped an Android AAB to inspect the contents, in the android/app/release directory. I have no idea why this affects running pod install but it always fails if the unzipped AAB exists, and always works after I delete it.

pskirkham avatar Aug 19 '21 12:08 pskirkham

Hi any update i still have this issue when using rn 0.64.2

sanguineman91 avatar Sep 15 '21 06:09 sanguineman91

This issue is still occurring for me with the following:

jtich avatar Oct 08 '21 23:10 jtich

There hasn't been any activity on this issue in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.

github-actions[bot] avatar Nov 26 '22 03:11 github-actions[bot]

I fixed this by deleting /node_modules and running npm install. I hope this helps someone!

andygphillips avatar Nov 04 '23 15:11 andygphillips