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.

Cannot resolve babel module when using react-scripts@next

See original GitHub issue

Is this a bug report?

Yes, for react-scripts 2.0. (edit: originally I had believed this to be related to workspaces, but after more testing, it is not - this happens without a monorepo/workspaces. All details below updated to reflect that with a simpler test case.)

Did you try recovering your dependencies?

Yes. I deleted both the workspace and CRA app node_modules and lock files, and reinstalled with yarn (v1.6.0); deleted everything again and tried with npm (v5.6.0) with the same result.

Which terms did you search for in User Guide?

I followed the steps outlined in the roadmap for react-scripts 2.0 to initialize the app.

Environment

MacOS High Sierra 10.134 node 10.1.0 yarn 1.6.0 create-react-app@next react-scripts@2.0.0-next.66cc7a90

I executed this command to init a new CRA2 app: npx create-react-app@next --scripts-version=2.0.0-next.66cc7a90 test

Steps to Reproduce

  1. Create a CRA2 app with the command above in the packages (or, in my example, “exercises” folder)
  2. In the App.js file, attempt to import getPrototypeOf from @babel/runtime/helpers/getPrototypeOf
  3. Run yarn start in either the CRA2 app or the workspace root

(Note: I discovered this issue originally when I installed semantic-ui-react and attempted to use one of its components, which resulted in this error. To simplify the demo I just attempted to import getPrototypeOf in App.js.)

Expected Behavior

CRA app compiles and runs

Actual Behavior

A compilation error occurs: Module not found: Can't resolve '@babel/runtime/helpers/getPrototypeOf' in '/Users/nloding/code/oss/cra2-workspace-broken-ref/src'

I also see this warning when installing the dependencies, I am unsure if it is related? npm WARN @babel/plugin-syntax-dynamic-import@7.0.0-beta.34 requires a peer of @babel/core@7.0.0-beta.34 but none is installed. You must install peer dependencies yourself.

Reproducible Demo

https://github.com/nloding/cra2-workspace-broken-ref

The broken line: https://github.com/nloding/cra2-workspace-broken-ref/blob/master/src/App.js#L6

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:11

github_iconTop GitHub Comments

1reaction
nlodingcommented, May 28, 2018

Got it, thanks - I’ll keep an eye out for the next alpha announcement and test it out.

0reactions
venikxcommented, Aug 29, 2018

Currently I’m running an ejected version on my local machine with an updated Jest version and when I push to the repo I make sure the tests don’t run, because they will fail with version the repo has. It’s a bit of a mess, but at least I can keep writing my tests now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to resolve module when using babel ... - Stack Overflow
I implemented the changes and now I get "Module not found: Can't resolve '@components/Tables' in 'C:\Users\enisr\Desktop\projects\pcPartPicker\ ...
Read more >
Cannot Resolve Imports when using babel-resolver
a team I'm working with is using babel-resolver which cuts down on all the crazy '../../../' Consequently in WebStorm I can no longer......
Read more >
How to enable optional chaining with Create React App and ...
requestAnimationFrame works only without using classes, how can I fix it? Error: Cannot find module 'babel-preset-react' - If you want to resolve "react",...
Read more >
babel-loader - webpack
This package allows transpiling JavaScript files using Babel and webpack. ... you'll need to add the babel-loader to the list of modules, like...
Read more >
eslint-import-resolver-babel-module - npm
babel -plugin-module-resolver resolver for eslint-plugin-import. Latest version: 5.3.1, last published: 2 years ago. Start 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