bundle.js:4387 Uncaught ReferenceError: process is not defined

Holyday33·2021년 12월 6일
1
/* @jsx React.createElement */
import React from 'react'
const element = (
  <div>
    <p>안녕!</p>
  </div>
)

console.log(element)

위와 같은 코드를 쓰니 다음과 같은 에러가 뜹니다.

bundle.js:4387 Uncaught ReferenceError: process is not defined
at Object. (bundle.js:4387)
at webpack_require (bundle.js:34578)
at fn (bundle.js:34789)
at Module. (bundle.js:4322)
at webpack_require (bundle.js:34578)
at bundle.js:35646
at bundle.js:35648

해결방법은 다음과 같습니다.

프로세스를 설치합니다.
npm i process

다음 코드를 입력하면 해결!

webpack.config.js

const webpack = require('webpack')
  ...
module.exports = {
  ...
  plugin:[
    ...
    new webpack.ProvidePlugin({
      process: 'process/browser',
    })
  ]
}
profile
Why so serious?

0개의 댓글