create-react-app: [Build] Failed to compile | Error: [BABEL] index.js Cannot find module './src/data'

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.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 12
  • Comments: 22 (7 by maintainers)

Most upvoted comments

@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.

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

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

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

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

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

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

thanks @Timer for being so helpful!

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