오류 'babel-core' 모듈을 찾을 수 없습니다.react.displays, webpack 및 express 서버 사용
달릴 때마다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'
}
]
}
}
패키지.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를 설치해야 합니다.
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
peer Dependecies가 자동으로 설치되지 않는 이유는 몇 번의 검색 작업 후 npm 블로그에서 확인되었습니다.
peerDependencies는 자동으로 설치되지 않습니다.
이 스레드에 대한 @Chetan의 답변에 추가:
나는 오늘 악셀 라우쉬메이어 박사의 책을 읽다가 이 문제에 부딪쳤다.책 한 권당babel-loader다운로드해야 합니다.babel-core뿐만 아니라.하지만 막상 해보니 그렇지 않아요.@the Jian의 답변과 관련이 있다고 생각합니다.
원래 패키지부터요.json은 이미 리스트 되어 있습니다.babel-loader의존관계로서 다음 명령을 실행하면 오류가 해결됩니다.
npm install babel-core --save-dev
npm install babel-register
이것으로 문제를 해결할 수 있습니다.또한 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
'codememo' 카테고리의 다른 글
| 레일 link_to: (0) | 2023.03.19 |
|---|---|
| WP_Query('orderby=post_date')가 워드프레스와 함께 작동하지 않습니다. (0) | 2023.03.19 |
| 아이템이 존재하는지 테스트하기 위해 MongoDB에 문의하는 방법 (0) | 2023.03.19 |
| Django Rest Framework 파일 업로드 (0) | 2023.03.19 |
| Oracle에서 변수를 선언하고 표시하는 방법 (0) | 2023.03.14 |