Description
It's quite frustrating that a very well documented issue is just automatically closed after a few months because it's marked stale, but I understand why such a thing would happen. Anyway, you can consider this a comment to this issue opened just a few months ago: #5865
(I'll even move my comment to that thread if it's unlocked and delete this issue once I move it there to keep things cleaner)
I am also having an unexpected token error on the first jsx angle bracket <
I have components I placed in my package.json, which are pointing to git repo urls. Everything was working, until I need to create some webpack aliases. So I had to eject, and then the first error I got was this unexpected token error.
I saw this related issue: #3491 But I'm quite sure @derpoho has exactly pinned the issue.
I looked through his repo demonstrating the issue, and wanted to note his changes from a fresh create-react-app:
-Added import Packaged from './components/Packaged'
to App.js
This folder is very very simple. Just package.json with main entry pointing to pure functional component that returns a div: https://github.com/derpoho/cra-packaged-components-error/tree/master/src/components/Packaged
Then he ejected.
Activity
devinrhode2 commentedon Mar 2, 2019
Also I can add that it chokes on the first line that contains a jsx
<
- even if that line of code is not the first line of jsx that would be executed in the app. (Cough cough - sorry I just explained the definition of a syntax error - but maybe it's helpful..)devinrhode2 commentedon Mar 2, 2019
Here's the full expanded copy of the error I get in my console
Of course the error from @derpoho's repo will be more illuminating
stale commentedon Apr 1, 2019
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.
supnate commentedon Apr 3, 2019
I just met the same issue and found a workaround. Since Babel reports syntax error it usually means it's not configured correctly. So I guess if a folder contains
package.json
but with no.babelrc
,babel.config.js
such files in parent folders then it thinks there's no config.So I created a
babel.config.js
in the project root rather that define it inpackage.json
. Then it works.My
babel.config.js
is as below:Note that you must contain
if (api.env("...
otherwise it throws errors. I don't know why maybeapi.env
does some tricky things.However, sub-folders with package.json just worked in my previous project with old cra and babel :-(
stale commentedon May 3, 2019
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.
stale commentedon May 8, 2019
This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.