[webpack] Cannet find module'babel-eslint'나오고.
9770 단어 JavaScriptwebpackBabeltech
오류 개요
다음 환경에서 오류가 발생했습니다.
웹 페이지가 v5로 업데이트되면 토할 것 같습니다.
"devDependencies": {
"babel-core": "^6.26.3",
"babel-jest": "^23.2.0",
"babel-preset-env": "^1.7.0",
"css-loader": "^0.28.11",
"eslint": "^5.0.1",
"eslint-config-airbnb": "17.0.0",
"eslint-loader": "^2.0.0",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.9.1",
"jest": "^23.2.0",
"jest-localstorage-mock": "^2.2.0",
"node-sass": "^4.9.0",
"sass-loader": "^7.0.3",
"style-loader": "^0.21.0",
"webpack": "^4.12.1",
"webpack-cli": "^3.0.8",
"webpack-dev-server": "^3.1.4"
},
"dependencies": {
"moment": "^2.22.2"
}
Error: Cannot find module 'babel-eslint'
에 부족하다고 여겨진babel-eslint를 설치한 후 다음 로그가 이번에 나왔습니다.gyp ERR! stack Error: `make` failed with exit code: 2
나는 약간 반했다. 단도직입적으로 말하면 웹 페이지의 config에 협조해야 할 것 같다.미리 이해해야 할 일 / 주석
2020년 말께 출시된 웹팩 v5는 config 설정을 통해 웹팩의 공식 창고를 더욱 떠들썩하게 만들었다.
이 프로젝트의 경우 웹 페이지의 버전이 현재 상태를 유지하기 위해 v4학과이지만 config의 느낌에 맞춰야 합니다.
구체적 해결 방법
패키지-lock을 사용합니다.json、/node_modules/、 ~/.node-gyp/폴더 삭제
$ rm package-lock.json && rm -rf node_modules && rm -rf ~/.node-gyp
재대량 설치 봉인(yarn은$ npm install
)$ yarn upgrade
에 babel-eslint 설치(yarn은 $ npm install --save-dev babel-eslint
$ yarn add --dev babel-eslint
집행(yarn은$ npm run dev-server
Before
webpack.config.js
module.exports = {
// other configs
module: {
{
test: /\.(js)$/,
exclude: /node_modules/,
loader: 'eslint-loader',
options: {
// eslint options
},
}],
}
}
webpack.config.jsmodule.exports = {
// other configs
module: {
{
test: /\.(js)$/,
exclude: /node_modules/,
// loader: 'eslint-loader',
use: [
{
loader: "eslint-loader",
query: {
name: 'bundle.js'
}
}
]
// options: {
// // eslint options
// },
}],
}
}
이렇게 하면 오류 로그가 사라지고 컴파일링이 순조롭게 끝난다.참조 소스
Reference
이 문제에 관하여([webpack] Cannet find module'babel-eslint'나오고.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://zenn.dev/arisa_dev/articles/webpack-cannot-find-module-babel-eslint텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)