Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Babel - Error: Cannot find module 'babel-runtime/helpers/typeof'

Transpiling via gulp-babel for the server and browserify with babelify for the client - using async and await in my code. These features seem to transform just fine, but... Error: Cannot find module 'babel-runtime/helpers/typeof'

Contents of .babelrc

{
  "presets": ["react", "es2015"],
  "plugins": [
    "transform-class-properties",
    "transform-async-to-generator",
    "transform-runtime"
  ]
}

Relevant contents of package.json

"babel-core": "6.3.13",
"babel-eslint": "4.1.6",
"babel-plugin-transform-async-to-generator": "6.3.13",
"babel-plugin-transform-class-properties": "6.3.13",
"babel-plugin-transform-runtime": "6.3.13",
"babel-preset-es2015": "6.3.13",
"babel-preset-react": "6.3.13",
"babelify": "7.2.0",
"browserify": "12.0.1",
"gulp-babel": "6.1.0",

I have found a few other mentions of this, many of which seem to lead here - https://github.com/babel/babel/issues/2954

But I am getting a 404 at the link above and indeed cannot see any issues related to babel - https://github.com/babel/babel/issues redirects to https://github.com/babel/babel/pulls

Any ideas?

like image 767
jerome Avatar asked Dec 16 '15 20:12

jerome


People also ask

Is it possible to call @Babel/runtime under /node_modules?

Calling any other modules available under /node_modules works fine. Need to be able to call @babel/runtime/... Note: "@babel/runtime": "^7.9.0" in dependencies added for testing if this can resolve the issue.

Why use the @Babel/plugin-transform-runtime plugin?

This duplication is sometimes unnecessary, especially when your application is spread out over multiple files. This is where the @babel/plugin-transform-runtime plugin comes in: all of the helpers will reference the module @babel/runtime to avoid duplication across your compiled output.

What is @Babel/runtime?

@babel/runtime is just the package that contains the implementations of the functions in a modular way.

Is it possible to reuse the output of a Babel class?

This is meant to be used as a runtime dependency along with the Babel plugin @babel/plugin-transform-runtime. Please check out the documentation in that package for usage. Sometimes Babel may inject some code in the output that is the same across files, and thus can be potentially re-used. For example, with the class transform (without loose mode):


1 Answers

Turns out I needed to take the install of babel-runtime, which I thought had been deprecated with the release of Babel v6.

like image 63
jerome Avatar answered Sep 18 '22 18:09

jerome