cli: Unable to do pod install. Throwing error use_native_modules!

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

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (3 by maintainers)

Most upvoted comments

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.

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

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