question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BABEL error when running `yarn` in create-react-app

See original GitHub issue

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes

yarn --version 1.5.1

Which terms did you search for in User Guide?

(Write your answer here if relevant.)

Environment

  1. node -v: v8.9.4
  2. npm -v: 5.6.0
  3. yarn --version (if you use Yarn): 1.5.1
  4. npm ls react-scripts (if you haven’t ejected): └── react-scripts@1.1.0 -> /Users/fratran/projects/create-react-app/packages/react-scripts extraneous

npm ERR! extraneous: react-scripts@1.1.0 /Users/fratran/projects/create-react-app/node_modules/react-scripts

Then, specify:

  1. Operating system: OSX Sierra 10.12.6
  2. Browser and version (if relevant):

Steps to Reproduce

(Write your steps here:)

  1. Clone CRA into a new folder (git clone https://github.com/facebook/create-react-app.git)
  2. Go to the created directory (cd create-react-app)
  3. Run Yarn (yarn)

Expected Behavior

node_modules folder gets generated, dependencies download without error, compiling iframeScripts.js finishes without error.

Actual Behavior

Failed to compile message occurs when compiling iframeScript.js followed by the following error

Compiling iframeScript.js
Failed to compile.

ERROR in ./src/iframeScript.js
Module build failed: TypeError: [BABEL] /Users/fratran/projects/create-react-app/packages/react-error-overlay/src/iframeScript.js: Cannot read property 'slice' of undefined (While processing: "/Users/fratran/projects/create-react-app/node_modules/babel-preset-react-app/index.js$3")
    at throwVersionError (/Users/fratran/projects/create-react-app/node_modules/@babel/helper-plugin-utils/lib/index.js:41:15)
    at Object.assertVersion (/Users/fratran/projects/create-react-app/node_modules/@babel/helper-plugin-utils/lib/index.js:11:11)
    at /Users/fratran/projects/create-react-app/node_modules/@babel/plugin-proposal-object-rest-spread/lib/index.js:15:7
    at /Users/fratran/projects/create-react-app/node_modules/@babel/helper-plugin-utils/lib/index.js:16:12
    at /Users/fratran/projects/create-react-app/node_modules/@babel/core/lib/config/index.js:167:14
    at cachedFunction (/Users/fratran/projects/create-react-app/node_modules/@babel/core/lib/config/caching.js:40:17)
    at loadPluginDescriptor (/Users/fratran/projects/create-react-app/node_modules/@babel/core/lib/config/index.js:202:28)
    at /Users/fratran/projects/create-react-app/node_modules/@babel/core/lib/config/index.js:59:16
    at Array.map (<anonymous>)
    at recurseDescriptors (/Users/fratran/projects/create-react-app/node_modules/@babel/core/lib/config/index.js:58:36)
    at recurseDescriptors (/Users/fratran/projects/create-react-app/node_modules/@babel/core/lib/config/index.js:92:27)
    at loadConfig (/Users/fratran/projects/create-react-app/node_modules/@babel/core/lib/config/index.js:108:6)
    at /Users/fratran/projects/create-react-app/node_modules/@babel/core/lib/transform.js:26:33
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
✨  Done in 4.52s.
✨  Done in 31.53s.

Reproducible Demo

You can reproduce this with this base repo, and I’ve experienced it on multiple coworker’s computers.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
existentialismcommented, Mar 15, 2018

For some context, in beta.41 we added a way for plugins to check/assert what version of Babel they’re being used with and throw a friendlier (irony, lol) error message.

Haven’t dug into this really, but it looks like proposal-object-rest-spread@beta.41 (from another dep) is getting loaded by CRA’s preset since it doesn’t have an explicit devDep on it.

I’ll push a PR to fix.

1reaction
sowhatdoidocommented, Mar 15, 2018

Just a side note, this is in the default next branch. I tried to replicate this in master and it works fine. Here are the results I expected and got:

Compiling iframeScript.js
Hash: b64068c463e855f59d32
Time: 3697ms
           Asset    Size  Chunks             Chunk Names
iframe-bundle.js  214 kB       0  [emitted]  main

Compiling index.js
Hash: 2a6020c2fd31665a904f
Time: 729ms
   Asset    Size  Chunks                    Chunk Names
index.js  415 kB       0  [emitted]  [big]  main

Compiled successfully!


Done in 6.49s.
Done in 342.70s.

The thing that is really strange though is I had this working in the next branch last night… didn’t turn off my computer or update anything… just deleted the test-app, tried to rerun yarn create-react-app test-app to test some changes for react-scripts when I first ran into the issue. Since then, I can replicate the issue on every machine I’ve tried by following the steps described above.

Read more comments on GitHub >

github_iconTop Results From Across the Web

babel-preset-react-app dependency error - Yarn 3 #11793
Describe the bug When attempting to use create-react-app with yarn 3, running the scripts returns the following error Error: [BABEL] ...
Read more >
react-scripts babel scripts error running with yarn on local ...
There might be a problem with the project dependency tree. It is likely not a bug in Create React App, but something you...
Read more >
How to resolve create-react-app babel-jest Error. - Medium
After creating my react app using the official create-react app. ... Run npm install or yarn, depending on the package manager you use....
Read more >
Create React App without Create React App - Bits and Pieces
Babel — used to convert ECMAScript 2015+ (ES6+) code into a backwards compatible version of JavaScript that can be run by older JavaScript...
Read more >
Getting Started - Create React App
If you've previously installed create-react-app globally via npm install -g create-react-app , we recommend you uninstall the package using ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found