Programing

'babel-core'모듈을 찾을 수 없음에 오류가 있습니다.

lottogame 2020. 10. 7. 07:12
반응형

'babel-core'모듈을 찾을 수 없음에 오류가 있습니다. react.js, 웹팩, 익스프레스 서버 사용


webpack터미널에서 실행할 때마다 다음 을 얻습니다.

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

ERROR in Cannot find module 'babel-core'

다음은 내 webpack.config.js 파일입니다.

module.exports = {
  entry: './app-client.js',
  output: {
    filename: 'public/bundle.js'
  },
  module: {
    loaders: [
      {
        exclude: /(node_modules|app-server.js)/,
        loader: 'babel'
      }
    ]
  }
}

package.json

{
  "name": "react",
  "version": "1.0.0",
  "description": "React polling app",
  "main": "app-client.js",
  "dependencies": {
    "babel-loader": "^6.2.2",
    "bootstrap": "^3.3.6",
    "express": "^4.13.4",
    "react": "^0.14.7"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

npm을 설치하는 동안 babel-loader와 babel-core를 dev-dependency로 설치해야합니다.

npm install babel-core babel-loader --save-dev

babel-loader 8+를 사용하려는 경우 : 'babel-core'대신 '@ babel / core'패키지로 설치되는 Babel 7.x가 필요합니다. 즉, 다음을 실행하십시오.

npm install --save-dev @babel/core

이 오류를 만나고 babel-core를 설치하여 해결했습니다. 그러나 흥미로운 점은 babel-core가 babel-loader의 peerDependencies에 존재한다는 것입니다.

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

peerDependecies가 자동으로 설치하지 왜, 몇 검색 작업 후 나는 발견 NPM 블로그에.

peerDependencies will not automatically install anymore.


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

npm install babel-register

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

참고URL : https://stackoverflow.com/questions/35215461/error-in-cannot-find-module-babel-core-using-react-js-webpack-and-express-s

반응형