Webpack 오류 해결 (1): ERROR in Entry module not found

웹 페이지에 있습니다.config.js가 약간의 변경을 한 후에 웹pack 명령을 실행하는데 갑자기 다음과 같은 오류가 발생했습니다.
ERROR in Entry module not found: 
Error: Cannot resolve 'file' or 'directory'
./es6/index.es6 in E:\Workspace\webpack-template

그러나 디렉터리 구조를 반복적으로 비교한 결과'es6/index.es6'가'E:\Workspace\webpack-template'에 있는 것을 발견했지만 왜 끝까지 찾지 못했을까?path를 도입하여 포털 파일을 절대 주소로 변경합니다.
let path = require('path')
module.exports = {
    entry: {
        index: path.resolve('./es6/index.es6')
    }
}

그러나 여전히 같은 오류를 보고합니다. "ERROR in Entry module not found".
설정에 따라 항목별로 제외합니다. 마지막으로resolve 설정 항목과 관련이 있습니다. 기본 설정을 덮어쓰고 extensions에 빈 문자열을 추가해야 합니다. 다음과 같습니다.
resolve: {
    //   , 
    extensions: ['', '.es6']
}

왜 이러지?공식적인 해석은 다음과 같다.
Using this will override the default array, meaning that webpack will no longer try to resolve modules using the default extensions. 
For modules that are imported with their extension, e.g. import SomeFile from "./somefile.ext", to be properly resolved, an empty string must be included in the array.

간단하게 말하면 기본 설정을 덮어쓰면 빈 문자열을 추가해야 합니다.

좋은 웹페이지 즐겨찾기