Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected token "<" on index.js after npm eject. #3491

Closed
alexispurslane opened this issue Nov 22, 2017 · 8 comments
Closed

Unexpected token "<" on index.js after npm eject. #3491

alexispurslane opened this issue Nov 22, 2017 · 8 comments

Comments

@alexispurslane
Copy link

alexispurslane commented Nov 22, 2017

Is this a bug report?

Yes

Can you also reproduce the problem with npm 4.x?

Yes

Which terms did you search for in User Guide?

token, eject, start, server, webpack, <

Environment

  1. node -v: 8.9.1
  2. npm -v: 5.5.1

Then, specify:

  1. Operating system: macOS 10.12.6
  2. Browser and version (if relevant): Firefox Quantum Developer Edition 58

Steps to Reproduce

  1. Eject your create-react-app
  2. Stop any currently running npm starts.
  3. Run npm start.
  4. Cry.

Expected Behavior

I expected the development server to run like normal and serve up my application with no errors, since I hadn't changed my project at all since ejection.

Actual Behavior

Instead, the development server spat out this error:

image

Reproducible Demo

I was able to reproduce this behaviour by deleting everything from my project except the basic files, index.js and App.js (which I made as basic as possible). You can get it here:
https://bitbucket.org/christopherdumas/kairos/branch/eject.

@Timer
Copy link
Contributor

Timer commented Nov 23, 2017

Unfortunately we'll need a copy of your project to help diagnose this. You can probably strip out everything but index.js.

@miraage
Copy link

miraage commented Nov 23, 2017

I guess you might have changed either package.json or config/webpack.config.dev.js.
Babel did not transpile JSX to React.createElement calls for some reason.

@alexispurslane
Copy link
Author

Here is my project: https://bitbucket.org/christopherdumas/kairos. I'll create an eject branch with everything unnecessary stripped out.

@alexispurslane
Copy link
Author

I haven't modified the webpack config at all, in fact the reason I ejected was in order to do that, but I haden't gotten to doing that when the error happened.

@alexispurslane
Copy link
Author

@Timer, I was able to reproduce the behavior by deleting everything from my project except the basic files, index.js and App.js like you said. You can get it here: https://bitbucket.org/christopherdumas/kairos/branch/eject.

@Timer
Copy link
Contributor

Timer commented Nov 23, 2017

@ChristopherDumas it's because you have a .babelrc file which doesn't contain anything required to compile React, ES6+, etc.
Delete that file and things should start working.

This commit would've caused the break.

Altering your .babelrc to add the react-app preset should also fix it.

@Timer
Copy link
Contributor

Timer commented Nov 23, 2017

As for your master branch, you removed vital configuration out of your package.json. Those entries were required for things to work. 😄

On a fresh eject you can find your babel configuration in package.json, which your .babelrc is overriding. If you'd like to remove it from package.json, copy it verbatim to .babelrc before making your modifications (react-app preset).

@Timer Timer closed this as completed Nov 23, 2017
@alexispurslane
Copy link
Author

Oh, okay. Thank you!

@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants