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

Created on 27 Dec 2017  路  15Comments  路  Source: parcel-bundler/parcel

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)
Bug

Most helpful comment

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.

All 15 comments

+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"]
    }
  }
}

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

@LancerComet @devongovett
But I would like to use a transform-runtime, because it will determine what you need to load, selective to load, and not pollution global variables.

transform-runtime not work in parcel +1, waiting for solution

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

screen shot 2017-12-31 at 00 18 15

I managed to solve this issue by removing the .cache folder.

Should be fixed by the above commit in v1.4.1.

Using 1.4.1 I am still getting an error. The build with babel-runtime. On my large prod react app the build succeeds however when running in the browser I get:

Uncaught Error: Cannot find module 'babel-runtime/core-js/object/set-prototype-of
    at newRequire (302803fbf98725642e67506b7792571d.js:33)
    at localRequire (302803fbf98725642e67506b7792571d.js:48)
    at Object.require.163.warning (302803fbf98725642e67506b7792571d.js:19286)
    at newRequire (302803fbf98725642e67506b7792571d.js:42)
    at localRequire (302803fbf98725642e67506b7792571d.js:48)
    at Object.require.147../MemoryRouter (302803fbf98725642e67506b7792571d.js:22063)
    at newRequire (302803fbf98725642e67506b7792571d.js:42)
    at localRequire (302803fbf98725642e67506b7792571d.js:48)
    at Object.require.2.react (302803fbf98725642e67506b7792571d.js:151353)
    at newRequire (302803fbf98725642e67506b7792571d.js:42)

That is with this .babelrc:

{
  "presets": ["env", "react"],
  "plugins": [
    "syntax-flow",
    "transform-flow-strip-types",
    "transform-decorators-legacy",
    "transform-runtime",
    "transform-object-rest-spread"
  ]
}

Similarly, on this test project:
https://github.com/mfpiccolo/parcel-demo-for-issues/tree/issues-408-mp

The build works and I am getting this error in the console:

parcel-demo-for-issues.js:73 Uncaught SyntaxError: Unexpected identifier

Line 73 is: import _Promise from "babel-runtime/core-js/promise";

parcel -V
1.4.1

@devongovett
It still doesn't work

Project
https://github.com/Topthinking/parcel-react.git

You can execute the following command

npm install
npm run dva

This error will then appear in the console

ccfdca706170b05661250a9fa899b9e8.js:33 Uncaught Error: Cannot find module 'babel-runtime/core-js/symbol/to-primitive'
    at newRequire (ccfdca706170b05661250a9fa899b9e8.js:33)
    at localRequire (ccfdca706170b05661250a9fa899b9e8.js:48)
    at Object.require.52 (ccfdca706170b05661250a9fa899b9e8.js:27050)
    at newRequire (ccfdca706170b05661250a9fa899b9e8.js:42)
    at localRequire (ccfdca706170b05661250a9fa899b9e8.js:48)
    at ccfdca706170b05661250a9fa899b9e8.js:31579
    at Object.require.33.react (ccfdca706170b05661250a9fa899b9e8.js:31580)
    at newRequire (ccfdca706170b05661250a9fa899b9e8.js:42)
    at localRequire (ccfdca706170b05661250a9fa899b9e8.js:48)
    at Object.require.3.babel-runtime/core-js/object/get-prototype-of (ccfdca706170b05661250a9fa899b9e8.js:35724)

Same issue here using "parcel-bundler": "1.4.1".

It seems that parceljs is not finding appropriate babel plugins, or not following babel preset requirements:

34097ee3e01edb4356caa2aa46757f82.js:33 Uncaught Error: Cannot find module 'babel-runtime/core-js/object/set-prototype-of'
    at newRequire (34097ee3e01edb4356caa2aa46757f82.js:33)
    at localRequire (34097ee3e01edb4356caa2aa46757f82.js:48)
    at Object.require.48.react (34097ee3e01edb4356caa2aa46757f82.js:18851)
    at newRequire (34097ee3e01edb4356caa2aa46757f82.js:42)
    at localRequire (34097ee3e01edb4356caa2aa46757f82.js:48)
    at Object.require.45../components/Provider (34097ee3e01edb4356caa2aa46757f82.js:21713)
    at newRequire (34097ee3e01edb4356caa2aa46757f82.js:42)
    at localRequire (34097ee3e01edb4356caa2aa46757f82.js:48)
    at Object.require.3.react (34097ee3e01edb4356caa2aa46757f82.js:42688)
    at newRequire (34097ee3e01edb4356caa2aa46757f82.js:42)
    at localRequire (34097ee3e01edb4356caa2aa46757f82.js:48)
    at Object.require.2.react-hot-loader (34097ee3e01edb4356caa2aa46757f82.js:47981)
    at newRequire (34097ee3e01edb4356caa2aa46757f82.js:42)
    at require.112 (34097ee3e01edb4356caa2aa46757f82.js:67)
    at 34097ee3e01edb4356caa2aa46757f82.js:72

.babelrc

{
    "presets": ["env", "react"],
    "plugins": [
        "react-hot-loader/babel",
        "transform-runtime",
        "transform-object-rest-spread"
    ]
}

@devongovett Can we reopen this issue?

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.

I am also getting this issue, any chance of that npm release?

ba11da78518d78710400d4b7c3148f5c.js:33 Uncaught Error: Cannot find module 'babel-runtime/core-js/object/keys

it looks like the fix was released yesterday in 1.5.0?

EDIT: 1.5.0 fixed this for me! 馃帀

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Niggler picture Niggler  路  3Comments

466023746 picture 466023746  路  3Comments

termhn picture termhn  路  3Comments

medhatdawoud picture medhatdawoud  路  3Comments

algebraic-brain picture algebraic-brain  路  3Comments