if it is a react-native project, you need to deal with flow syntax and install @ babel/preset-flow
Ordinary js project
Installation
yarn add -D babel-loader @babel/core @babel/preset-env
.babelrc
{
"presets": [
"@babel/preset-env"
]
}
Webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.(js|jsx|ts|tsx)$/,
use: ['babel-loader'],
}
],
}
}
Installation
yarn add -D babel-loader @babel/core @babel/preset-env @babel/preset-typescript
.babelrc
{
"presets": [
"@babel/preset-env",
"@babel/preset-typescript"
]
}
Webpack.config.js Same as above
The above supplementary installation
yarn add -D @babel/preset-react
.babelrc
{
"presets": [
"@babel/preset-env",
"@babel/preset-typescript",
"@babel/preset-react"
]
}
Webpack.config.js Same as above
Supplemental installation above
yarn add -D @babel/preset-flow
.babelrc
{
"presets": [
"@babel/preset-env",
"@babel/preset-typescript",
"@babel/preset-react",
"@babel/preset-flow"
]
}
webpack.config.js Same as above