Rad Blog

Archive

index.js에서 'Preset files are not allowed to export objects' 에러가 발생한 이유

문제 발생 상황

https://medium.com/uva-mobile-devhub/set-up-react-in-your-django-project-with-webpack-4fe1f8455396

  • 위의 글을 보고 따라가는데 6번 과정에서 아래의 명령 입력시 발생한 문제
./node_modules/.bin/webpack --config webpack.config.js

해결 방법

  • 아래는 해결 방법의 원문(영문)을 옮긴 글이다.

That is due to outdated babel packages being used. The babel project, just like most other active Javascript projects, have moved on to using scope packages. Hence, the package names starts with @babel

If you are using yarn, follow the below one:

Step 1: Remove the old packages

$ yarn remove babel-core babel-loader babel-preset-env babel-preset-react

step 2: Add the new packages

$ yarn add -D @babel/core babel-loader @babel/preset-env @babel/preset-react

If you are using npm, follow the below one:

step 1: Remove the old packages

$ npm uninstall babel-core babel-loader babel-preset-env babel-preset-react

step 2: Add the new packages

$ npm add -D @babel/core babel-loader @babel/preset-env @babel/preset-react

Step 3: common to both npm or yarn

After installing the newer packages, remember to update your .babelrc presets from react to @babel/preset-react. Here is a simple example

{
    "presets": [
        "@babel/preset-env",
        "@babel/preset-react"
    ]
}

참고한 곳

comments powered by Disqus