본문 바로가기

Error

[React.js] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.

Situation

webpack.config.js에서 웹팩을 셋팅한 뒤, 실행하려고 터미널에 npx webpack을 입력하자 에러 발생

Error

[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
 - configuration.node should be one of these:
   false | object { __dirname?, __filename?, global? }
   -> Include polyfills or mocks for various node stuff.
   Details:
    * configuration.node should be false.
    * configuration.node should be an object:
      object { __dirname?, __filename?, global? }

Solution

구글링 결과, 위의 오류가 발생했을 때는 코드에 오타가 있는지부터 확인해보자

코드가 길어서 한줄한줄 확인하기 힘든 경우, 에러 메시지 내용 중에 이 부분을 주목해 코드 속에서 찾아보면 오타를 좀 더 쉽게 발견할 수 있을 거다

- configuration.node should be one of these:

나 역시 단순한 오타 때문에 에러가 발생했던 것이다😂

 

node : 'development' → mode : 'development'


And more...

mode : 'development' ?

웹팩 모드 : 개발용이라는 뜻. 실서비스일 때 > 'production' 이라고 써줘야 함

 

webpack 실행하는 법

  • 터미널 > npx webpack 입력
  • package.json > script > 'dev' : 'webpack' 으로 수정 > 터미널 > npm run dev
  •