react-native: Error when linking: "Expected "/*", "//" or "{" but "<" found"

Issue Description

When running react-native link, I get some kind of parse error. However, this parse error is impossible to debug, because it doesn’t give me any filename, line number, or column number.

I was told to file an issue at https://github.com/rnpm/rnpm/issues but that directed me to file issues here instead.

Steps to Reproduce / Code Snippets

% react-native link
rnpm-install info Android module react-native-maps is already linked
rnpm-install ERR! It seems something went wrong while linking. Error: Expected "/*", "//" or "{" but "<" found.
Please file an issue here: https://github.com/rnpm/rnpm/issues

Expected "/*", "//" or "{" but "<" found.

Expected Results

No idea. I did it because these instructions tell me to.

Additional Information

  • React Native version:
% react-native --version
react-native-cli: 1.0.0
react-native: 0.33.0
  • Platform(s) (iOS, Android, or both?): Both
  • Operating System (macOS, Linux, or Windows?): macOS

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 25
  • Comments: 73 (2 by maintainers)

Commits related to this issue

Most upvoted comments

+1 same problem as Deevent’s I change react-native install react-native-fbsdk to npm install react-native-fbsdk@0.6.0 --save react-native link react-native-fbsdk

This really should not be closed. This has been an ongoing problem for some time.

Ran into this after react-native install react-native-fbsdk. Xcode then failed to open the project, and looking at the git diff I discovered my project.pbxproj file was written incorrectly like so:

HEADER_SEARCH_PATHS = "$(SRCROOT)/../node_modules/some-package""$(SRCROOT)/../node_modules/react-native-fbsdk/ios/RCTFBSDK/**";

All was well once I changed to format:

HEADER_SEARCH_PATHS = (
	"$(SRCROOT)/../node_modules/some-package",
	"$(SRCROOT)/../node_modules/react-native-fbsdk/ios/RCTFBSDK/**"
);

@Tawfeekamr On Monday morning I set up a fb login for android. With version 0.6.0 there was a bug with java dependencies. After I fixed it with android everything was fine. Today I wanted to set up on iOs but because of this problem I did not have time. I’ll set up tomorrow if everything works out. I will rely on this instruction and from react-native-fbsdk examples =)

Update:

npm install react-native-fbsdk@0.6.0 --save react-native link react-native-fbsdk npm install plist xcode adm-zip --save-dev cp ./node_modules/react-native-fbsdk/ios_setup.js ./ios_setup.js node ./ios_setup.js [App ID] [App Name]

add changes from this file (don’t forget change “HelloFacebook” to your app)

I have the exact same issue trying to link react-native-fbsdk and I’ve checked my *.pbxproj and it’s all good.

In my case,react-native-fbsdk was also giving this error when linking and the way I solved it with 0.6.1 was to open node_modules/react-native-fbsdk/ios/ios.xcodeproj on XCode, go to the Build Settings of the project, change some key => save => revert key value => save.

After that, the project.pbxproj inside ios.xcodeproj was updated to the new format (checked with a texteditor) and I could finally run react-native link react-native-fbsdk

I had something similar too, I was getting:

$ react-native link react-native-code-push
? What is your CodePush deployment key for Android (hit <ENTER> to ignore) 
rnpm-install info Linking react-native-code-push android dependency 
rnpm-install info Android module react-native-code-push has been successfully linked 
rnpm-install ERR! It seems something went wrong while linking. Error: Expected "{" but "/" found. 
Please file an issue here: https://github.com/facebook/react-native/issues 

Expected "{" but "/" found.

Comparing with an older version of my code which worked, it looked like the problem was inside my iOS project.pbxproj file. The top line was:

 // !$*UTF8*$!
{

Removing the leading space fixed the problem for me:

// !$*UTF8*$!
{

I was using 0.6.1 and I got the same error, so I did:

npm install react-native-fbsdk@0.6.0 --save react-native link react-native-fbsdk

Works well!

Downgrading react-native-fbsdk from 0.6.1 to 0.6.0 solved the problem for me!

The fix that worked for me for 0.6.1

cd to_your_project npm install react-native-fbsdk@0.6.1 --save open node_modules/react-native-fbsdk/ios/ios.xcodeproj create some group delete the group react-native link react-native-fbsdk

This was reliably working for me on one system and not on another, so managed to narrow this down to being an encoding issue. We were able to confirm this using a freshly init’ed project using the latest cli (2.0.1).

A successful workaround for me is to explicitly unset the LANG environment variable when running link or install (install is a wrapper around npm install/yarn add and link):

LANG= react-native link react-native-fbsdk

Does this work for anyone else?

@BATMAH69 @edencakir I can confirm that it just worked for me 🎉 . Thx for the hint @BATMAH69

i use a cleanup/install script which works for me, maybe can help you guys as well package.json

  "dependencies": {
    "moment": "^2.18.1",
    "radio-button-react-native": "^1.1.6",
    "react": "16.0.0-alpha.12",
    "react-native": "0.47.1",
    "react-native-blur": "^3.1.3",
    "react-native-camera": "0.10",
    "react-native-circular-progress": "^0.0.8",
    "react-native-datepicker": "^1.6.0",
    "react-native-easy-grid": "^0.1.15",
    "react-native-easy-toast": "^1.0.6",
    "react-native-fbsdk": "0.6.0",
    "react-native-fs": "^2.5.1",
    "react-native-i18n": "^2.0.4",
    "react-native-linear-gradient": "^2.2.0",
    "react-native-loader": "^1.1.0",
    "react-native-router-flux": "4.0.0-beta.17",
    "react-native-status-bar-size": "^0.3.2",
    "react-native-video": "^1.2.0",
    "react-redux": "^5.0.6",
    "redux": "^3.7.2",
    "redux-thunk": "^2.2.0",
    "sha1": "^1.1.1"
  },
  "devDependencies": {
    "babel-eslint": "^7.2.3",
    "babel-jest": "20.0.3",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-preset-react-native": "2.1.0",
    "eslint": "^4.4.1",
    "eslint-config-google": "^0.9.1",
    "eslint-plugin-class-property": "^1.0.6",
    "eslint-plugin-react": "^7.2.1",
    "jest": "20.0.4",
    "react-test-renderer": "~15.6.1"
  },

cleanup.sh

#!/usr/bin/env bash

watchman watch-del-all 1>/dev/null

rm -rf node_modules 1>/dev/null
rm -rf yarn.lock  1>/dev/null
rm -rf package-lock.json 1>/dev/null
rm -rf $TMPDIR/react-packager-* 1>/dev/null
rm -rf ios/build 1>/dev/null

npm cache clear --force -s 1>/dev/null
npm cache verify 1>/dev/null

yarn
yarn add react-native-fbsdk@0.6.0

react-native link

feel free to ignore the cleanup part on the script

for some unknown reasons if you don’t install react-native-fbsdk@0.6.0 before linking, it will return error in the react-native link i’ll let you guys know if i figured it out 😃

@edencakir Seems its work =)

I downgraded to react-native-fbsdk@0.6.0 and it worked for me.

For Android, react-native@0.47.1

@vvavepacket versions 0.5.1 and 0.6.1 were broken by commits on Jun 16, 2017 Version 0.5.1 was working until this commits. So you can update version to 0.6.0.

@BATMAH69 … and that worked?

Still have the issue on the latest version. Reverted to 0.6.0 and it links fine.

The problem is - as far as I see - that the project.pbxproj gets corrupted. I assume this may have multiple reasons.

In my case:

HEADER_SEARCH_PATHS = "$(SRCROOT)/node_modules/react-native/Libraries/PushNotificationIOS";

was incorrectly changed to

HEADER_SEARCH_PATHS = "$(SRCROOT)/node_modules/react-native/Libraries/PushNotificationIOS""PATH_TO_ANOTHER_DEPENDENCY";

instead of

HEADER_SEARCH_PATHS = (
    "$(SRCROOT)/node_modules/react-native/Libraries/PushNotificationIOS",
    "PATH_TO_ANOTHER_DEPENDENCY",
);

My steps to solve it:

  1. Open diff (e.g. git diff or diff tool of trust).
  2. Search for suspicious changes.
  3. Fix it:
    • Option 1: Fix suspicious changes by hand.
    • Option 2: Revert suspicious code block(s). Open XCode (XCode opens the project when all corrupted changes are reverted). Fix it in XCode. If you don’t know how to fix it: Often, there is manual which provides hints.
  4. Rerun react-native link or react-native link <MODULE-NAME>.

@jaimecorrea ,your solution worked for me. Thanks…

Thanks for the hint @BATMAH69. Worked for me as well. I unlinked and removed and then installed version 0.6.0 using Yarn and linked without any issues.

+1, this is happening to me on every link no matter what library, same versions as OP.