• 카테고리

    질문 & 답변
  • 세부 분야

    프론트엔드

  • 해결 여부

    미해결

npm run build 에러 궁금합니다!

21.03.09 23:32 작성 조회수 107

0

실습 중 math.js 를 모듈로 만들어 import받는 과제중인데요

{
  "name": "sample2",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "build": "webpack"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "babel": "^6.23.0",
    "dotenv": "^8.2.0",
    "react": "^17.0.1"
  },
  "devDependencies": {
    "webpack": "^5.24.4",
    "webpack-cli": "^4.5.0"
  },
  "type": "module"
}

type module 을 추가하니 webpack.config.js에서 ReferenceError: module is not defined 에러가 납니다. 문제를 해결하고 싶네요 ㅠㅠ

import path from 'path'

module.exports = {
    mode: "development",
    entry: {
        main: "./src/app.js",
    },
    output: {
        filename: "[name].js",
        path: path.resolve("./dist"),
    }
}

답변 1

답변을 작성해보세요.

0

type이란 모듈을 추가하는 과정에서 문제를 겪으신건가요? package.json을 보니깐 패키지 설치가 안되었거나 잘못된것 같아요. npm으로 패키지를 설치하면 dependencies난 devDependencies 부분에 추가되는데요. 파일 내용을 보면 없는것 같네요. type: module이란 부분이 있는데 이게 설치하시려는 흔적이 아닌가 추측해 봅니다.