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

Cannot find module babel-preset-react-app/node_modules/@babel/runtime/helpers/slicedToArray #7183

Closed
pehhuishi opened this issue Jun 7, 2019 · 46 comments
Labels

Comments

@pehhuishi
Copy link

Error Message on the terminal: Cannot find module '/Users/pehhuishi/code/react/practice/react-practice/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/slicedToArray

Not sure why after I installed bootstrap 3 "npm install bootstrap@3.x.x ­­save" I hit the error above. Hope someone can help to resolve. I need to use bootstrap 3 on react.

Thanks for helping !

@Pajn
Copy link
Contributor

Pajn commented Jun 7, 2019

Please post the full error message so that the problematic module can be identified.
Bootstrap does not have a dpendency on @babel/runtime so if they do require that one, it's a bug there. However this is only a guess without the full error message.

@pehhuishi
Copy link
Author

pehhuishi commented Jun 7, 2019

Hi @Pajn ,

Here is the full error message from the browser:

formatWebpackMessages.js:9 Uncaught Error: Cannot find module '/Users/pehhuishi/code/react/practice/react-practice/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/slicedToArray'
at webpackMissingModule (formatWebpackMessages.js:9)
at Object../node_modules/react-dev-utils/formatWebpackMessages.js (formatWebpackMessages.js:9)
at webpack_require (bootstrap:781)
at fn (bootstrap:149)
at Object../node_modules/react-dev-utils/webpackHotDevClient.js (webpackHotDevClient.js:23)
at webpack_require (bootstrap:781)
at fn (bootstrap:149)
at Object.0 (serviceWorker.js:135)
at webpack_require (bootstrap:781)
at checkDeferredModules (bootstrap:45)

@errk01
Copy link

errk01 commented Jun 7, 2019

Try: npm add @babel/runtime

@GomatoX
Copy link

GomatoX commented Jul 5, 2019

@errk01 Sadly but with yarn workspaces it's not working.

@bugzpodder
Copy link

bugzpodder commented Jul 5, 2019

@GomatoX try:

"nohoist": [
      "**/babel-preset-react-app/@babel/runtime"
]```
in your workspace package.json

remove all node_modules and re-run yarn install

@rafaelim
Copy link

rafaelim commented Jul 5, 2019

I'm have likely the same issue but with the objectSpread2, i don't what is causing this, but some how the babel-preset-react-app is requiring the @babel/runtime@7.5.0

@anhquande
Copy link

I have the same problem, but with objectSpread2
I tried the solution suggested by @bugzpodder and @errk01, but it does not work either.

My workaround is to force babel-preset-react-app to use newer version 7.5.0 instead of 7.4.3.
Add the following configuration in your package.json

  "resolutions": {
    "**/@babel/runtime": "7.5.0"
  },

It may be related to babel/babel#10169

@mingenesis
Copy link

Thank you @anhquande. It's work for me.

@GomatoX
Copy link

GomatoX commented Jul 8, 2019

@bugzpodder Thanks, it seems working.

For yarn workspaces I just have to add module in global scope: yarn add -W @babel/runtime
And then use your solution with "nohoist"

"nohoist": [
    "**/babel-preset-react-app/@babel/runtime"
]

@VasiliKubarka
Copy link

VasiliKubarka commented Jul 10, 2019

try:
yarn add @babel/runtime
and in .babelrc

 "presets": [
    ["react-app", { "absoluteRuntime": false }],
  ]

it solves both incorrect module import and absolute path

@rafaelim
Copy link

For me the latest version from babel fixed. I just remove the yarn.lock and run yarn install

@fikar46
Copy link

fikar46 commented Jul 11, 2019

Try: npm add @babel/runtime

thank you so much

@tonysepia
Copy link

tonysepia commented Jul 23, 2019

This was sufficient for me,thank you!
npm add @babel/runtime

@charleslukes
Copy link

This happened to me right now, comes as a result of me composing my state files into containers.
Even when I tried refactoring my files back to default it still brought that error.

use: npm add @babel/runtime and restart the app.

@shaneiadt
Copy link

npm i @babel/runtime

Solved it for me, thanks @fikar46 👍

@saeedhassankhan
Copy link

npm i @babel/runtime

Solved it for me, thanks @fikar46 👍

thanks it workes for me

mathiashoeld added a commit to openkfw/TruBudget that referenced this issue Aug 14, 2019
* Create new component for project card
* Set fixed height of project cards
* Make project cards slightly wider
* Make content of project cards scrollable
* Refactor styles
* Add babel runtime due to compile error, see facebook/create-react-app#7183
@carlosdiver
Copy link

The same problem happened to me.
I run npm add @babel/runtime, removed yarn.lock, run yarn install and restart the project.
Solved!!

Thanks all

@gferrarocamus
Copy link

None of the above worked for me. I had to remove both package-lock.json AND node_modules and install again:
$ rm -rf package-lock.json node_modules
$ npm install

Solved!

@JaccoGoris
Copy link

I've tried all steps here without any luck, whenever I delete everything and start over (on 3.1.0 or 3.1.1) I end up with the following message:

Cannot find module 'repo-path-here/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/interopRequireDefault' from 'setupTests.js'.

because those files are hoisted to the main @babel folder.
I can run the code but all the tests break

@mamunur121
Copy link

npm i @babel/runtime
It solved my problem and running properly.

Planeshifter added a commit to isle-project/isle-dashboard that referenced this issue Sep 21, 2019
@JulienPradet
Copy link

In my case, I had an issue with my babel-loader cache.

By default it's in node_modules/.cache/babel-loader. But it may be overidden by your webpack configuration under the option cacheDirectory of your babel-loader rule.

Make sure to delete it before running your scripts and it might solve your issues.

@shauryakapoor
Copy link

Try: npm add @babel/runtime

I can not thank you enough. I appreciate your time and effort for helping us out @errk01 .

Quick Question: How did you know that this command would fix our error? I am trying to comprehend how you were able to acquire the knowledge base where you knew that this exact command would fix our error.

@patrykkowalski0617
Copy link

hi,

I had this message: "Cannot find module (..) babel-preset-react-app \ node_modules \ @babel \ runtime / helpers / slicedToArray"

The funny thing is that I trun of computer with working, commited project yesturday, and today i see this bug message in my console. Another funny thing, it was beggining of my porject, so when I couldn't find solution I started new one and just after changing some text on default react app page, bug couse again. I tryed new projects and it is always the same, witch maked my furious.

Finaly I deleted node_modules folder and taped npm i - working now...

@MatBasiak
Copy link

get the same error after

npm install --save styled-components
npm add @babel/runtime

fix the problem

@yagoazedias
Copy link

yagoazedias commented Oct 7, 2019

@VasiliKubarka tip woked to me, but is removing the absolute imports of my react components

@maheshauti96
Copy link

maheshauti96 commented Oct 13, 2019

I deleted node_modules folder and did npm i. its working now 😂

@akinorimiz
Copy link

I could fix this issue with yarn test --clearCache.

@pnguy55
Copy link

pnguy55 commented Nov 20, 2019

Try: npm add @babel/runtime

works here

@hugoh59
Copy link

hugoh59 commented Nov 24, 2019

None of the above worked for me...

@PatienceD
Copy link

PatienceD commented Dec 2, 2019

I've tried everything everyone above has suggested, and none of it has worked for me. I still get the initial error:
"Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: [BABEL] C:\Users\patie\OneDrive\Documents\GitHub\School-Info\myapp\node _modules\webpack\buildin\global.js: Cannot find module './src/data'"

this is on a brand new react app, I haven't even added anything into it.

@keponk
Copy link

keponk commented Dec 2, 2019

+1
Been searching around for a bit now clearing cache and following the simplest rules and still get the same error on a clean create-react-app

Html Webpack Plugin:

  Error: Child compilation failed:
  Module build failed (from ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js):
  Error: [BABEL] /path_to_project/node_modules/webpack/buildin/global.js: Cannot find module './src/data'
  Require stack:
  - /path_to_project/node_modules/core-js-compat/helpers.js
  - /path_to_project/node_modules/core-js-compat/get-modules-list-for-target-version.js
  - /path_to_project/node_modules/babel-preset-react-app/node_modules/@babel/preset-env/lib/polyfills/corejs3/entry-plugin.js
  - /path_to_project/node_modules/babel-preset-react-app/node_modules/@babel/preset-env/lib/index.js
  - /path_to_project/node_modules/babel-preset-react-app/dependencies.js
  - /path_to_project/node_modules/react-scripts/node_modules/@babel/core/lib/config/files/plugins.js
  - /path_to_project/node_modules/react-scripts/node_modules/@babel/core/lib/config/files/index.js
  - /path_to_project/node_modules/react-scripts/node_modules/@babel/core/lib/index.js
  - /path_to_project/node_modules/react-scripts/node_modules/babel-loader/lib/index.js
  - /path_to_project/node_modules/loader-runner/lib/loadLoader.js
  - /path_to_project/node_modules/loader-runner/lib/LoaderRunner.js
  - /path_to_project/node_modules/webpack/lib/NormalModule.js
  - /path_to_project/node_modules/webpack/lib/NormalModuleFactory.js
  - /path_to_project/node_modules/webpack/lib/Compiler.js
  - /path_to_project/node_modules/webpack/lib/webpack.js
  - /path_to_project/node_modules/react-scripts/scripts/start.js (While processing: "/path_to_project/node_modules/babel-preset-react-app/dependencies.js$0$9")
  
  - loader.js:780 Function.Module._resolveFilename
    internal/modules/cjs/loader.js:780:15
  
  - loader.js:685 Function.Module._load
    internal/modules/cjs/loader.js:685:27
  
  - loader.js:838 Module.require
    internal/modules/cjs/loader.js:838:19
  
  - helpers.js:74 require
    internal/modules/cjs/helpers.js:74:18
  
  - helpers.js:3 Object.
    [test_webcam]/[core-js-compat]/helpers.js:3:14
  
  - loader.js:945 Module._compile
    internal/modules/cjs/loader.js:945:30
  
  - loader.js:962 Object.Module._extensions..js
    internal/modules/cjs/loader.js:962:10
  
  - loader.js:798 Module.load
    internal/modules/cjs/loader.js:798:32
  
  - loader.js:711 Function.Module._load
    internal/modules/cjs/loader.js:711:12
  
  - loader.js:838 Module.require
    internal/modules/cjs/loader.js:838:19
  
  - helpers.js:74 require
    internal/modules/cjs/helpers.js:74:18
  
  - get-modules-list-for-target-version.js:2 Object.
    [test_webcam]/[core-js-compat]/get-modules-list-for-target-version.js:2:51
  
  - loader.js:945 Module._compile
    internal/modules/cjs/loader.js:945:30
  
  - loader.js:962 Object.Module._extensions..js
    internal/modules/cjs/loader.js:962:10
  
  - loader.js:798 Module.load
    internal/modules/cjs/loader.js:798:32
  
  
  - Error: [BABEL] /path_to_project/node_modules/webpack/buildin/global.js: Cannot find module './src/data'
  
  - Require stack:
  
  - - /path_to_project/node_modules/core-js-compat/helpers.js
  
  - - /path_to_project/node_modules/core-js-compat/get-modules-list-for-target-version.js
  
  - - /path_to_project/node_modules/babel-preset-react-app/node_modules/@babel/preset-env/lib/polyfills/corejs3/entry-plugin.js
  
  - - /path_to_project/node_modules/babel-preset-react-app/node_modules/@babel/preset-env/lib/index.js
  
  - - /path_to_project/node_modules/babel-preset-react-app/dependencies.js
  
  - - /path_to_project/node_modules/react-scripts/node_modules/@babel/core/lib/config/files/plugins.js
  
  - - /path_to_project/node_modules/react-scripts/node_modules/@babel/core/lib/config/files/index.js
  
  - - /path_to_project/node_modules/react-scripts/node_modules/@babel/core/lib/index.js
  
  - - /path_to_project/node_modules/react-scripts/node_modules/babel-loader/lib/index.js
  
  - - /path_to_project/node_modules/loader-runner/lib/loadLoader.js
  
  - - /path_to_project/node_modules/loader-runner/lib/LoaderRunner.js
  
  - - /path_to_project/node_modules/webpack/lib/NormalModule.js
  
  - - /path_to_project/node_modules/webpack/lib/NormalModuleFactory.js
  
  - - /path_to_project/node_modules/webpack/lib/Compiler.js
  
  - - /path_to_project/node_modules/webpack/lib/webpack.js
  
  - - /path_to_project/node_modules/react-scripts/scripts/start.js (While processing: "/path_to_project/node_modules/babel-preset-react-app/dependencies.js$0$9")
  
  - Module build failed (from ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js):
  
  - Error: [BABEL] /path_to_project/node_modules/webpack/buildin/module.js: Cannot find module './src/data'
  
  - Require stack:
  
  - - /path_to_project/node_modules/core-js-compat/helpers.js
  
  - - /path_to_project/node_modules/core-js-compat/get-modules-list-for-target-version.js
  
  - - /path_to_project/node_modules/babel-preset-react-app/node_modules/@babel/preset-env/lib/polyfills/corejs3/entry-plugin.js
  
  - - /path_to_project/node_modules/babel-preset-react-app/node_modules/@babel/preset-env/lib/index.js
  
  - - /path_to_project/node_modules/babel-preset-react-app/dependencies.js
  
  - - /path_to_project/node_modules/react-scripts/node_modules/@babel/core/lib/config/files/plugins.js
  
  - - /path_to_project/node_modules/react-scripts/node_modules/@babel/core/lib/config/files/index.js
  
  - - /path_to_project/node_modules/react-scripts/node_modules/@babel/core/lib/index.js
  
  - - /path_to_project/node_modules/react-scripts/node_modules/babel-loader/lib/index.js
  
  - - /path_to_project/node_modules/loader-runner/lib/loadLoader.js
  
  - - /path_to_project/node_modules/loader-runner/lib/LoaderRunner.js
  
  - - /path_to_project/node_modules/webpack/lib/NormalModule.js
  
  - - /path_to_project/node_modules/webpack/lib/NormalModuleFactory.js
  
  - - /path_to_project/node_modules/webpack/lib/Compiler.js

@endel
Copy link

endel commented Dec 2, 2019

Also having the same issue right now, maybe some internal dependency had a breaking change we don't know about?

@benshanahan1
Copy link

+1 Seems like this is happening to a bunch of people right now.

@Timer
Copy link
Contributor

Timer commented Dec 2, 2019

For all users experiencing this right now, please do not respond to this thread.

Follow these issues:
#8062
npm/cli#545

Edit: temporarily locking to prevent 33+ people from getting pinged for messages until the current issue self-resolves.

@facebook facebook locked as off-topic and limited conversation to collaborators Dec 2, 2019
@facebook facebook unlocked this conversation Dec 3, 2019
@rbrewington

This comment has been minimized.

@MrBhati

This comment has been minimized.

@MeMihir

This comment has been minimized.

@thebiltheory
Copy link

thebiltheory commented Feb 3, 2020

None of the above works.
Anyone knows what would be the potential causes?

UPDATE:
Running the following worked out.

react-scripts test --clearCache

Run tests again

react-scripts test

@timhitchins

This comment has been minimized.

@VituBR19
Copy link

Try: npm add @babel/runtime

It works for me, thanks @errk01

@defusioner
Copy link

Installing babel runtime in CRA environment... Use @thebiltheory suggestion

@sbcreates
Copy link

I could fix this issue with yarn test --clearCache.

This solution worked for me! Thanks @akinorimiz

I'm using yarn workspaces in a monorepo. Adding a new dep to one of my packages caused the error others were having running tests. I tried adding @babel/runtime, removing all node_modules, running yarn install again with no luck.

@stale
Copy link

stale bot commented Apr 9, 2020

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 stale bot added the stale label Apr 9, 2020
@stale
Copy link

stale bot commented Apr 14, 2020

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.

@stale stale bot closed this as completed Apr 14, 2020
AlbertoPdRF added a commit to AlbertoPdRF/tisn.app that referenced this issue Apr 16, 2020
I don't know what happened exactly, but running `npm add @babel/runtime` and `npm install` before trying again fixed the issue.

Source of the fix: facebook/create-react-app#7183 (comment).
AlbertoPdRF added a commit to AlbertoPdRF/tisn.app that referenced this issue Apr 16, 2020
I don't know what happened exactly, but running `npm add @babel/runtime` and `npm install` before trying again fixed the issue.

Source of the fix: facebook/create-react-app#7183 (comment).
timurbazhirov added a commit to Exabyte-io/materials-designer that referenced this issue Apr 16, 2020
- updated babel core and present env to ^7.1.0
- updated babel runtime and corejs2 to ^7.5.0
- added babel-preset-react-app to devDependencies and edited .babelrc
for it
- followed facebook/create-react-app#7183
@lock lock bot locked and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests