ERROR in Cannot find module 'babel-core'. using react.js, webpack, and express server

前端 未结 5 1211
时光取名叫无心
时光取名叫无心 2020-12-22 22:37

Whenever I run webpack in the terminal I get:

Hash: efea76b1048c3a97b963
Version: webpack 1.12.13
Time: 33ms
    + 1 hidden modules

ERROR in Ca         


        
相关标签:
5条回答
  • 2020-12-22 22:51

    You should install babel-loader and babel-core as dev-dependency while npm install.

    npm install babel-core babel-loader --save-dev
    
    0 讨论(0)
  • 2020-12-22 23:03

    Adding to @Chetan's answer on this thread:

    I ran into this issue today while following through Dr. Axel Rauschmayer's book here. Per book, babel-loader should download babel-core as well. However this is not the case when I tried it out. I think this relates to @theJian's answer.

    Since the original package.json already lists babel-loader as dependency, running the following command resolved the error.

    npm install babel-core --save-dev
    
    0 讨论(0)
  • 2020-12-22 23:06

    For those wanting to use babel-loader 8+: it requires Babel 7.x,, which is to be installed as the '@babel/core' package instead of 'babel-core'. In other words, run:

    npm install --save-dev @babel/core
    
    0 讨论(0)
  • 2020-12-22 23:06

    I just meet this error, and solved by installing babel-core. But the interesting is I found babel-core does exist in babel-loader's peerDependencies.

    https://github.com/babel/babel-loader/blob/master/package.json

    Why peerDependecies not install automatically, after a few searching work I found this in npm blog.

    peerDependencies will not automatically install anymore.

    0 讨论(0)
  • 2020-12-22 23:06
    npm install babel-register
    

    This can solve your issue. Additionally, add babelrc .babelrc { "presets" : ["es2015", "react"] }

    0 讨论(0)
提交回复
热议问题