• 카테고리

    질문 & 답변
  • 세부 분야

    프론트엔드

  • 해결 여부

    미해결

웹팩 설정을 마쳤는데 npx webpack 했을 때 원하는 결과가 안 나옵니다.

23.08.11 07:20 작성 조회수 703

0

WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value.
Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/

ERROR in main
Module not found: Error: Can't resolve './src' in 'C:\study\zerocho\lecture'
resolve './src' in 'C:\study\zerocho\lecture'
  using description file: C:\study\zerocho\lecture\package.json (relative path: .)
    Field 'browser' doesn't contain a valid alias configuration
    using description file: C:\study\zerocho\lecture\package.json (relative path: ./src)
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        C:\study\zerocho\lecture\src is not a file
      .js
        Field 'browser' doesn't contain a valid alias configuration
        C:\study\zerocho\lecture\src.js doesn't exist
      .json
        Field 'browser' doesn't contain a valid alias configuration
        C:\study\zerocho\lecture\src.json doesn't exist
      .wasm
        Field 'browser' doesn't contain a valid alias configuration
        C:\study\zerocho\lecture\src.wasm doesn't exist
      as directory
        existing directory C:\study\zerocho\lecture\src
          using description file: C:\study\zerocho\lecture\package.json (relative path: ./src)
            using path: C:\study\zerocho\lecture\src\index
              using description file: C:\study\zerocho\lecture\package.json (relative path: ./src/index)
                no extension
                  Field 'browser' doesn't contain a valid alias configuration
                  C:\study\zerocho\lecture\src\index doesn't exist
                .js
                  Field 'browser' doesn't contain a valid alias configuration
                  C:\study\zerocho\lecture\src\index.js doesn't exist
                .json
                  Field 'browser' doesn't contain a valid alias configuration
                  C:\study\zerocho\lecture\src\index.json doesn't exist
                .wasm
                  Field 'browser' doesn't contain a valid alias configuration
                  C:\study\zerocho\lecture\src\index.wasm doesn't exist

webpack 5.88.2 compiled with 1 error and 1 warning in 196 ms

처음에 위와 같은 에러코드가 나와서 lecture안에 src폴더를 만들고 그안에 index.js, index.json, index.wasm 파일을 직접 생성해주었습니다.

그 다음에는 아래와 같은 에러코드가 나오면서 main,js 파일이 생성됐는데 안에는 아무 내용도 없습니다.

asset main.js 0 bytes [emitted] [minimized] (name: main)
./src/index.js 1 bytes [built] [code generated]

WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value.
Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/

webpack 5.88.2 compiled with 1 warning in 212 ms
PS C:\study\zerocho\lecture> npx run
Need to install the following packages:
  run@1.4.0
Ok to proceed? (y) y
Found 0 argument(s). Expected one or more.
Usage: 
  runjs [SIGNAL] somecode.js [--args]
Ex:
  runjs somecode.js --args
  runjs SIGUSR2 somecode.js --args

그리고 webpack.config.js에 보면 강의에서 했던대로

mode: "development",

라고 이미 적용되어있는 상태입니다.

답변 2

·

답변을 작성해보세요.

0

아니면 module.exports 같은 데 오타 있는 거 아닌가요?

0

폴더 구조가 처음부터 틀렸을겁니다. package.json이랑 webpack.config.js 그리고 기타 파일들이 같은 폴더에 있어야합니다.