parcel: Cannot find module 'babel-runtime....'

parcel verion 1.3.1

I upgraded the version, and then the error occurred

.babelrc

{
    "presets": [
        "react",
        "es2015",
        "stage-0"
    ],
    "plugins": [
        "babel-plugin-transform-decorators-legacy",
        "babel-plugin-transform-runtime"
    ]
}
Uncaught Error: Cannot find module 'babel-runtime/core-js/symbol/to-primitive'
    at newRequire (ccfdca706170b05661250a9fa899b9e8.js:32)
    at localRequire (ccfdca706170b05661250a9fa899b9e8.js:47)
    at Object.require.10 (ccfdca706170b05661250a9fa899b9e8.js:18751)
    at newRequire (ccfdca706170b05661250a9fa899b9e8.js:41)
    at localRequire (ccfdca706170b05661250a9fa899b9e8.js:47)
    at Object.require.3.babel-runtime/core-js/object/define-property (ccfdca706170b05661250a9fa899b9e8.js:22245)
    at newRequire (ccfdca706170b05661250a9fa899b9e8.js:41)
    at localRequire (ccfdca706170b05661250a9fa899b9e8.js:47)
    at Object.require.2.react (ccfdca706170b05661250a9fa899b9e8.js:22316)
    at newRequire (ccfdca706170b05661250a9fa899b9e8.js:41)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Ok that was a separate issue, where some node module used ES6 module syntax instead of commonjs, probably via package.json module field. We run babel-plugin-transform-es2015-modules-commonjs to convert those to commonjs, but babel was also traversing up to your project to find a babelrc and thus enabling the transform-runtime plugin as well. 1a853be disables babelrc detection when only compiling es6 modules to commonjs. Let me know if it fixes your problem. I’ll get a release to npm out shortly.

@devongovett Can we reopen this issue?

Yeah, I am getting this with a module that needs the babel-runtime.

screen shot 2017-12-31 at 00 18 15

I give up using transform-runtime and use babel-polyfill instead. Everything goes well so far. @Topthinking

+1, but I have tried 1.2.1 and it’s still throwing this error. First time using parcel.

Seems babel-runtime isn’t bundled to js file in browser, it throws error when evaluating modules[name] in newRequire(). The name is a string like "babel-runtime/core-js/***", not a number-index.

package.json

"devDependencies": {
    "babel-core": "^6.26.0",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-polyfill": "^6.26.0",
    "babel-preset-env": "^1.6.1",
    "babel-preset-stage-2": "^6.24.1",
    "babel-register": "^6.26.0",
    "babel-runtime": "^6.26.0",
    "parcel-bundler": "^1.3.1",
    "parcel-plugin-pug": "^0.2.1",
    "parcel-plugin-vue": "^1.4.0",
    "pug": "^2.0.0-rc.4",
    "stylus": "^0.54.5",
    "typescript": "^2.6.2"
  },
  "dependencies": {
    "vue": "^2.5.13"
  }

.babelrc

{
  "presets": [
    ["env", {
      "targets": {
        "browsers": ["last 3 versions", "> 2%", "ie >= 9", "Firefox >= 30", "Chrome >= 30"]
      },
      "modules": false,
      "loose": true,
      "useBuiltIns": true
    }],
    "stage-2"
  ],
  "plugins": [
    "transform-runtime"
  ],
  "env": {
    "test": {
      "plugins": ["transform-es2015-modules-commonjs"]
    }
  }
}