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

[Build] Failed to compile | Error: [BABEL] index.js Cannot find module './src/data' #8062

Closed
Fantasim opened this issue Dec 2, 2019 · 22 comments

Comments

@Fantasim
Copy link

Fantasim commented Dec 2, 2019

The bug itself

Getting this error when running : yarn build

Creating an optimized production build...
Failed to compile.

./src/index.js
Error: [BABEL] /root/my-app/src/index.js: Cannot find module './src/data'
Require stack:

  • /root/my-app/node_modules/core-js-compat/helpers.js
  • /root/my-app/node_modules/core-js-compat/get-modules-list-for-target-version.js
  • /root/my-app/node_modules/@babel/preset-env/lib/polyfills/corejs3/entry-plugin.js
  • /root/my-app/node_modules/@babel/preset-env/lib/index.js
  • /root/my-app/node_modules/babel-preset-react-app/create.js
  • /root/my-app/node_modules/babel-preset-react-app/index.js
  • /root/my-app/node_modules/@babel/core/lib/config/files/plugins.js
  • /root/my-app/node_modules/@babel/core/lib/config/files/index.js
  • /root/my-app/node_modules/@babel/core/lib/index.js
  • /root/my-app/node_modules/babel-loader/lib/index.js
  • /root/my-app/node_modules/loader-runner/lib/loadLoader.js
  • /root/my-app/node_modules/loader-runner/lib/LoaderRunner.js
  • /root/my-app/node_modules/webpack/lib/NormalModule.js
  • /root/my-app/node_modules/webpack/lib/NormalModuleFactory.js
  • /root/my-app/node_modules/webpack/lib/Compiler.js
  • /root/my-app/node_modules/webpack/lib/webpack.js
  • /root/my-app/node_modules/react-scripts/scripts/build.js (While processing: "/root/my-app/node_modules/babel-preset-react-app/index.js$0$29")

My environment and project settings

node version : 12.3.1
npm version : 6.12.1
yarn version : 1.19.2

package.json

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "connected-react-router": "^6.6.0",
    "hammerjs": "^2.0.8",
    "is_js": "^0.9.0",
    "ismobilejs": "^1.0.3",
    "promise": "^8.0.3",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-redux": "^7.1.3",
    "react-router": "^5.1.2",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.2.0",
    "redux": "^4.0.4",
    "redux-devtools-extension": "^2.13.8",
    "redux-thunk": "^2.3.0",
    "sanitize.css": "^11.0.0",
    "tinycolor2": "^1.4.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

machine:
Linux ary-prod 4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24 06:16:15 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

I tried to run the same app on an ubuntu machine with the same versions of npm yarn and node, and it works, but not on this one.

@freelari
Copy link

freelari commented Dec 2, 2019

I'm having the same issue on CentOS on a vanilla app (I was installing it) but with 'npm start'.

@Fantasim
Copy link
Author

Fantasim commented Dec 2, 2019

Retried on my local machine, and I get the same problem now (I didn't get it few days ago).

@EugeneSnihovsky
Copy link

Same error on Mac OS Mojave. After reinstall node modules all builds failed with this error

@jrapoport
Copy link

macOS Catalina & Docker (node:latest) / Linux

@Timer
Copy link
Contributor

Timer commented Dec 2, 2019

There was a bad publish by an upstream package -- this will self resolve in a while.

Please follow npm/cli#545 for updates. npm seems to be having a service degradation and is serving 1hr+ old stale content.

@hecomp
Copy link

hecomp commented Dec 2, 2019

HI same for me..

image

@hecomp
Copy link

hecomp commented Dec 2, 2019

@Timer I tried that it didn't work for me.

@krckyboy
Copy link

krckyboy commented Dec 2, 2019

I'm getting this error even with a new project npx create-react-app test npm start.

Error that I get:

Error: [BABEL] C:\Users\krcky\Desktop\Projects\test\node_modules\react-dev-utils\webpackHotDevClient.js: Cannot find module './src/data'
Require stack:

  • C:\Users\krcky\Desktop\Projects\test\node_modules\core-js-compat\helpers.js
  • C:\Users\krcky\Desktop\Projects\test\node_modules\core-js-compat\get-modules-list-for-target-version.js
  • C:\Users\krcky\Desktop\Projects\test\node_modules\babel-preset-react-app\node_modules@babel\preset-env\lib\polyfills\corejs3\entry-plugin.js
  • C:\Users\krcky\Desktop\Projects\test\node_modules\babel-preset-react-app\node_modules@babel\preset-env\lib\index.js
  • C:\Users\krcky\Desktop\Projects\test\node_modules\babel-preset-react-app\dependencies.js
  • C:\Users\krcky\Desktop\Projects\test\node_modules@babel\core\lib\config\files\plugins.js
  • C:\Users\krcky\Desktop\Projects\test\node_modules@babel\core\lib\config\files\index.js
  • C:\Users\krcky\Desktop\Projects\test\node_modules@babel\core\lib\index.js
  • C:\Users\krcky\Desktop\Projects\test\node_modules\babel-loader\lib\index.js
  • C:\Users\krcky\Desktop\Projects\test\node_modules\loader-runner\lib\loadLoader.js
  • C:\Users\krcky\Desktop\Projects\test\node_modules\loader-runner\lib\LoaderRunner.js
  • C:\Users\krcky\Desktop\Projects\test\node_modules\webpack\lib\NormalModule.js
  • C:\Users\krcky\Desktop\Projects\test\node_modules\webpack\lib\NormalModuleFactory.js
  • C:\Users\krcky\Desktop\Projects\test\node_modules\webpack\lib\Compiler.js
  • C:\Users\krcky\Desktop\Projects\test\node_modules\webpack\lib\webpack.js
  • C:\Users\krcky\Desktop\Projects\test\node_modules\react-scripts\scripts\start.js (While processing: "C:\Users\krcky\Desktop\Projects\test\node_modules\babel-preset-react-app\dependencies.js$0$9")

@Timer
Copy link
Contributor

Timer commented Dec 2, 2019

@hecomp there's no instructions you can follow to resolve this currently. Please wait for npm to purge or update their edge caches!


To clarify, there is nothing we can do to fix this. Please be patient, it will resolve in time.

Once it's resolved, you'll need to deeply upgrade dependencies by running yarn upgrade.

If you use npm, you may need to delete package-lock.json and re-run npm install to fix it.

@themre
Copy link
Contributor

themre commented Dec 2, 2019

thanks @Timer for being so helpful!

@krckyboy
Copy link

krckyboy commented Dec 2, 2019

I've just created a new project and it seems to work as intended now.

Edit:

Made it work in an existing project by running these steps:

  1. Delete node modules
  2. Delete package-lock.json
  3. npm i

@hecomp
Copy link

hecomp commented Dec 2, 2019

@hecomp there's no instructions you can follow to resolve this currently. Please wait for npm to purge or update their edge caches!

To clarify, there is nothing we can do to fix this. Please be patient, it will resolve in time.

Once it's resolved, you'll need to deeply upgrade dependencies by running yarn upgrade.

If you use npm, you may need to delete package-lock.json and re-run npm install to fix it.

@Timer thanks for the input. I'll wait then.

@hecomp
Copy link

hecomp commented Dec 2, 2019

I've just created a new project and it seems to work as intended now.

Edit:

Made it work in an existing project by running these steps:

  1. Delete node modules
  2. Delete package-lock.json
  3. npm i

@krckyboy I'll try again.

@hecomp
Copy link

hecomp commented Dec 2, 2019

@Timer @krckyboy is fixed now. Thanks y'all.

@arpitjain-in
Copy link

arpitjain-in commented Dec 3, 2019

I'm still facing this issue.

Html Webpack Plugin:
  Error: Child compilation failed:
  Module build failed (from ./node_modules/babel-loader/lib/index.js):
  Error: [BABEL] <app-path>/node_modules/webpack/buildin/global.js: Cannot find module './src/data' (While processing: "<app-path>/node_modules/babel-preset-react-app/dependencies.js$0$9")
  
  - loader.js:636 Function.Module._resolveFilename
    internal/modules/cjs/loader.js:636:15

@Timer
Copy link
Contributor

Timer commented Dec 3, 2019

@arpitjain-in

You need to deeply upgrade dependencies by running yarn upgrade.

If you use npm, you need to delete package-lock.json and re-run npm install to fix it.

@arpitjain-in
Copy link

arpitjain-in commented Dec 3, 2019

@Timer Not able to run even after following below steps: -

  1. Delete node modules
  2. Delete package-lock.json
  3. npm i

@Timer
Copy link
Contributor

Timer commented Dec 3, 2019

Are you using a registry mirror? Please run npm ls core-js-compat and post your package.json.

@arpitjain-in
Copy link

@Timer

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-scripts": "3.2.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

@Timer
Copy link
Contributor

Timer commented Dec 3, 2019

Please run npm ls core-js-compat.

@arpitjain-in
Copy link

@Timer

my-app@0.1.0 <path>/my-app
└─┬ react-scripts@3.2.0
  ├─┬ @svgr/webpack@4.3.2
  │ └─┬ @babel/preset-env@7.7.4
  │   └── core-js-compat@3.4.6 
  └─┬ babel-preset-react-app@9.0.2
    └─┬ @babel/preset-env@7.6.0
      └── core-js-compat@3.4.6  deduped

@Timer
Copy link
Contributor

Timer commented Dec 3, 2019

You are still on an old version of core-js-compat@3.4.6.
Be sure you are following these instructions: #8062 (comment).

If that doesn't work, please try creating a project from scratch to be sure you get core-js-compat@3.4.7.

If you need further help please open a new issue and other maintainers may be able to help you.

@facebook facebook locked as resolved and limited conversation to collaborators Dec 3, 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

10 participants