Babel 5 plugin is being run with an unsupported Babel version - reactjs

After I installed relay-query plugin with yarn add -D babel-plugin-react-relay, and after running the dev server, I get this error:
Error: [BABEL] /Users/nemanja/sites/tictacturing/src/index.js: The (relay-query) Babel 5 plugin is being run with an unsupported Babel version. (While processing: "/Users/nemanja/sites/tictacturing/node_modules/babel-plugin-react-relay/lib/index.js")
at Array.reduce (<anonymous>)
This is my package.json file:
{
"name": "tictacturing",
"version": "0.1.0",
"private": true,
"dependencies": {
"#babel/core": "7.1.0",
"#svgr/webpack": "2.4.1",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "9.0.0",
"babel-jest": "23.6.0",
"babel-loader": "8.0.4",
"babel-plugin-named-asset-import": "^0.2.3",
"babel-preset-react-app": "^6.1.0",
"bfj": "6.1.1",
"case-sensitive-paths-webpack-plugin": "2.1.2",
"chalk": "2.4.1",
"css-loader": "1.0.0",
"dotenv": "6.0.0",
"dotenv-expand": "4.2.0",
"eslint": "5.6.0",
"eslint-config-react-app": "^3.0.5",
"eslint-loader": "2.1.1",
"eslint-plugin-flowtype": "2.50.1",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-jsx-a11y": "6.1.2",
"eslint-plugin-react": "7.11.1",
"file-loader": "2.0.0",
"fork-ts-checker-webpack-plugin-alt": "0.4.14",
"fs-extra": "7.0.0",
"html-webpack-plugin": "4.0.0-alpha.2",
"identity-obj-proxy": "3.0.0",
"jest": "23.6.0",
"jest-pnp-resolver": "1.0.1",
"jest-resolve": "23.6.0",
"mini-css-extract-plugin": "0.4.3",
"optimize-css-assets-webpack-plugin": "5.0.1",
"pnp-webpack-plugin": "1.1.0",
"postcss-flexbugs-fixes": "4.1.0",
"postcss-loader": "3.0.0",
"postcss-preset-env": "6.0.6",
"postcss-safe-parser": "4.0.1",
"react": "^16.6.3",
"react-app-polyfill": "^0.1.3",
"react-dev-utils": "^6.1.1",
"react-dom": "^16.6.3",
"react-relay": "^1.7.0",
"resolve": "1.8.1",
"sass-loader": "7.1.0",
"style-loader": "0.23.0",
"terser-webpack-plugin": "1.1.0",
"url-loader": "1.1.1",
"webpack": "4.19.1",
"webpack-dev-server": "3.1.9",
"webpack-manifest-plugin": "2.0.4",
"workbox-webpack-plugin": "3.6.3"
},
"scripts": {
"start": "GRAPHQL_ENDPOINT=https://api.graph.cool/relay/v1/cjoyiidl5gzv901148dsyafg1 node scripts/start.js",
"build": "GRAPHQL_ENDPOINT=https://api.graph.cool/relay/v1/cjoyiidl5gzv901148dsyafg1 node scripts/build.js",
"test": "node scripts/test.js"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts"
],
"resolver": "jest-pnp-resolver",
"setupFiles": [
"react-app-polyfill/jsdom"
],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
"<rootDir>/src/**/?(*.)(spec|test).{js,jsx,ts,tsx}"
],
"testEnvironment": "jsdom",
"testURL": "http://localhost",
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
"^.+\\.module\\.(css|sass|scss)$"
],
"moduleNameMapper": {
"^react-native$": "react-native-web",
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"web.js",
"js",
"web.ts",
"ts",
"web.tsx",
"tsx",
"json",
"web.jsx",
"jsx",
"node"
]
},
"babel": {
"plugins": [
"react-relay"
],
"presets": [
"react-app"
]
},
"devDependencies": {
"babel-plugin-react-relay": "^0.10.0",
"babel-plugin-relay": "^1.7.0",
"graphql": "^14.0.2"
}
}
How to resolve this issue?

Since you are using react16 there is no need to eject to add the custom environment variable. Your custom environment variable must begin with REACT_APP_ in your script. This will solve the compatible issue.
{
"name": "tictacturing",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.6.3",
"react-dom": "^16.6.3",
"react-router": "^3.2.1",
"react-scripts": "2.1.1"
},
"scripts": {
"start": "REACT_APP_GRAPHQL_ENDPOINT=https://api.graph.cool/relay/v1/cjoyiidl5gzv901148dsyafg1 react-scripts start",
"build": "REACT_APP_GRAPHQL_ENDPOINT=https://api.graph.cool/relay/v1/cjoyiidl5gzv901148dsyafg1 react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"babel-plugin-react-relay": "^0.10.0"
}
}

I think there is an upgrade for graphQL that is not applied in relay.
so for running the react application, you can use the previous version:
"scripts": {
"start": "GRAPHQL_ENDPOINT=https://api.graph.cool/relay/v1/cixqegi9u003g0196b2rtnhqu node scripts/start.js",
"build": "GRAPHQL_ENDPOINT=https://api.graph.cool/relay/v1/cixqegi9u003g0196b2rtnhqu node scripts/build.js",
"test": "node scripts/test.js --env=jsdom"

you shoud install babel by npm instead of yarn like below:
npm install -D babel-plugin-react-relay

Related

React app rewired , Installing module federation with webpack

I am using below code to install module federation plugin on top of react app rewired :
const ModuleFederationPlugin =
require("webpack/lib/container/ModuleFederationPlugin");
module.exports = {
webpack: function(config, env) {
config.externals = function(context, request, callback) {
if (/canvg|pdfmake/.test(request)) {
return callback(null, "commonjs " + request);
}
callback();
};
config.plugins.push(new ModuleFederationPlugin({
name: "app_1",
filename: "remoteEntry.js",
remotes: {
app_2: "app_2#http://localhost:8081/remoteEntry.js",
},
}));
return config;
},
};
Here is my package.json:
{
"name": "Sample_app",
"version": "0.1.358",
"dependencies": {
"#amcharts/amcharts4": "^4.10.20",
"#deck.gl/mesh-layers": "^8.6.8",
"#emotion/react": "^11.7.1",
"#material-ui/core": "^4.12.3",
"#material-ui/icons": "^4.11.2",
"#material-ui/lab": "^4.0.0-alpha.60",
"#mui/icons-material": "^5.1.1",
"#mui/material": "^5.1.1",
"#mui/styled-engine-sc": "^5.1.0",
"#mui/styles": "^5.1.1",
"#reactour/tour": "^2.9.0",
"#testing-library/jest-dom": "^5.11.4",
"#testing-library/react": "^11.2.7",
"#testing-library/user-event": "^12.1.10",
"#wsp/map-gl": "^2.1.11",
"#wsp/map-react": "^1.1.2",
"axios": "^0.24.0",
"classnames": "^2.3.1",
"dayjs": "^1.10.7",
"express": "^4.17.1",
"ignore-styles": "^5.0.1",
"jest-fetch-mock": "^3.0.3",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.21",
"lodash.debounce": "^4.0.8",
"md5-file": "^5.0.0",
"mui-datatables": "^4.0.0",
"node": "^16.13.1",
"react": "^17.0.2",
"react-data-export": "^0.6.0",
"react-dom": "^17.0.2",
"react-redux": "^7.2.6",
"react-router-dom": "5.2.0",
"react-scripts": "4.0.3",
"react-select": "^5.4.0",
"redux": "^4.1.2",
"redux-mock-store": "^1.5.4",
"redux-saga": "^1.1.3",
"styled-components": "^5.3.3",
"web-vitals": "^1.0.1"
},
"scripts": {
"start:local": "react-app-rewired start",
"start": "REACT_APP_ENV_HOST=$REACT_APP_ENV_HOST node --max-http-header-size 16384 build/server",
"build": "REACT_APP_ENV_HOST=$REACT_APP_ENV_HOST react-app-rewired build && cp -R ./server/* ./build && npm run moveFiles",
"test": "react-scripts test",
"test:coverage": "react-scripts test --coverage --watchAll=false",
"eject": "react-scripts eject",
"moveFiles": "cd build && mkdir channelperformance && cp -r ./static ./channelperformance/static",
"storybook": "start-storybook -p 6006 -s public",
"build-storybook": "build-storybook -s public",
"test:update": "react-scripts test -u"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
],
"overrides": [
{
"files": [
"**/*.stories.*"
],
"rules": {
"import/no-anonymous-default-export": "off"
}
}
]
},
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx}",
"!/node_modules/",
"!src/coverage/**",
"!src/index.js",
"!src/stories/**"
],
"coveragePathIgnorePatterns": [
"/src/constants",
"/src/routes",
"/src/helper",
"/src/reportWebVitals.js",
"/src/components/Drilldown/DownloadMuiTable",
"/src/components/Drilldown/ReactVirtualized",
"/src/components/Drilldown/Common/ChannelBreakdown.js"
],
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\](?!(#amcharts)\\/).+\\.js$"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"resolutions": {
"babel-eslint": "^10.0.0"
},
"devDependencies": {
"#e2e-test-utils/ui-shield": "^3.0.3",
"#e2e-test-utils/ui-shield-utilities": "^4.1.5-0",
"#storybook/addon-actions": "^6.5.10",
"#storybook/addon-essentials": "^6.5.10",
"#storybook/addon-interactions": "^6.5.10",
"#storybook/addon-links": "^6.5.10",
"#storybook/builder-webpack4": "^6.5.10",
"#storybook/manager-webpack4": "^6.5.10",
"#storybook/node-logger": "^6.5.10",
"#storybook/preset-create-react-app": "^3.2.0",
"#storybook/react": "^6.5.10",
"#storybook/testing-library": "^0.0.13",
"#wojtekmaj/enzyme-adapter-react-17": "^0.6.6",
"babel-jest-amcharts": "^0.0.2",
"enzyme": "^3.11.0",
"enzyme-to-json": "^3.4.4",
"eslint": "^7.28.0",
"prettier": "2.3.1",
"react-app-rewired": "^2.2.1",
"redux-devtools-extension": "^2.13.9"
}
}
However it throws an error saying "Cannot read properties of undefined (reading 'includes')". I think it's having a conflict with some library .
Please help. if any integration examples with MF plugin, please provide those links.

Set the `meta.hasSuggestions` property to `true`. `meta.docs.suggestion` is ignored by ESLint

I am trying to build the react.js project with npm run build, I am getting following error, I have tried many solution but nothing is working for me.
**Failed to compile.**
Rules with suggestions must set the `meta.hasSuggestions` property to `true`.
`meta.docs.suggestion` is ignored by ESLint.
Occurred while linting
/Users/e0658897/Desktop//Electrical%20-
%20Web%20Portal/src/reportWebVitals.ts:6
Rule: "#typescript-eslint/no-floating-promises"
This breaks all other linting. I've tried adding the following to my .eslintrc.js:
meta: {
hasSuggestions: true
},
which gives me the following error:
UnhandledPromiseRejectionWarning: Error: ESLint configuration in .eslintrc.js is invalid:
- Unexpected top-level property "meta".
Package.json
{
"name": "proxusweb",
"version": "0.1.0",
"private": true,
"dependencies": {
"#brightlayer-ui/icons-mui": "^2.8.1",
"#brightlayer-ui/react-auth-workflow": "^2.4.0",
"#brightlayer-ui/react-components": "^5.3.3",
"#brightlayer-ui/react-themes": "^6.1.0",
"#material-ui/core": "^4.11.4",
"#material-ui/icons": "^4.11.2",
"#material-ui/lab": "^4.0.0-alpha.60",
"axios": "^0.26.0",
"date-fns": "^2.28.0",
"i18next": "^19.9.2",
"jspdf": "^2.5.1",
"jspdf-autotable": "^3.5.23",
"react": "^17.0.2",
"react-app-polyfill": "^3.0.0",
"react-dom": "^17.0.2",
"react-i18next": "^11.15.3",
"react-router": "^5.2.1",
"react-router-dom": "^5.3.0",
"react-scripts": "5.0.0",
"web-vitals": "^0.2.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint \"src/**/**.{ts,tsx}\"",
"lint:fix": "eslint \"src/**/**.{ts,tsx}\" --fix",
"prettier": "prettier \"src/**/**.{ts,tsx,js,jsx,json,css,scss,html}\" --write",
"prettier:check": "prettier \"src/**/**.{ts,tsx,js,jsx,json,css,scss,html}\" --check"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"#brightlayer-ui/eslint-config": "^2.0.5",
"#brightlayer-ui/prettier-config": "^1.0.3",
"#testing-library/jest-dom": "^5.16.1",
"#testing-library/react": "^11.2.7",
"#testing-library/user-event": "^13.5.0",
"#types/enzyme-adapter-react-16": "^1.0.6",
"#types/jest": "^26.0.24",
"#types/node": "^12.20.42",
"#types/react": "^17.0.38",
"#types/react-dom": "^17.0.11",
"#types/react-router-dom": "^5.3.3",
"#typescript-eslint/eslint-plugin": "^4.33.0",
"#typescript-eslint/parser": "^4.33.0",
"#wojtekmaj/enzyme-adapter-react-17": "^0.6.6",
"enzyme": "^3.11.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.2.1-rc.1-next-f0dd459e0-20220301",
"prettier": "^2.5.1",
"typescript": "^4.5.5"
},
"prettier": "#brightlayer-ui/prettier-config"
}
.eslinrc.js
module.exports = {
root: true,
parser: '#typescript-eslint/parser',
extends: ['#brightlayer-ui/eslint-config/tsx'],
// meta:{
// hasSuggestions: true
// },
parserOptions: {
project: "./tsconfig.json",
},
env: {
browser: true
},
rules: {
// "#typescript-eslint/explicit-function-return-type": "off",
"#typescript-eslint/explicit-function-return-type": [
"error",
{
"allowExpressions": true
}
],
"no-unused-vars": "off",
"no-undef": "off",
"arrow-body-style": "off",
"#typescript-eslint/no-unused-vars": "off",
'no-console': 'off',
"no-alert": "off",
"react-hooks/exhaustive-deps": "off",
"react-hooks/rule-of-hooks": "off",
},
};
All I found about this case https://eslint.org/docs/user-guide/migrating-to-8.0.0#-rules-require-metahassuggestions-to-provide-suggestions
But I didn't successfully remove the problem, only solution for now is to turn off the rule that's causing it
I was getting the same error when I was running my React.js application, you can see it in the image below:
Running the following command solved the problem: npm install -D eslint-plugin-react-hooks#next
I figured it out reading this GitHub discussion: Bug: Rules with suggestions must set the meta.hasSuggestions property to true

React App Not Loading into The Packaged Electron App

I'm trying to package my react app with electron 8. I've followed the instructions in this article and made the necessary changes to suit my code:
https://medium.com/#johndyer24/building-a-production-electron-create-react-app-application-with-shared-code-using-electron-builder-c1f70f0e2649
Here's what I'm currently seeing after packaging.
Here's my package.json
{
"homepage": "./",
"name": "Asset_Viewer",
"version": "0.1.0",
"private": true,
"dependencies": {
"#babel/core": "7.9.0",
"#svgr/webpack": "4.3.3",
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.5.0",
"#testing-library/user-event": "^7.2.1",
"#typescript-eslint/eslint-plugin": "^2.10.0",
"#typescript-eslint/parser": "^2.10.0",
"babel-eslint": "10.1.0",
"babel-jest": "^24.9.0",
"babel-loader": "8.1.0",
"babel-plugin-named-asset-import": "^0.3.6",
"babel-preset-react-app": "^9.1.2",
"bootstrap": "^4.5.2",
"camelcase": "^5.3.1",
"case-sensitive-paths-webpack-plugin": "2.3.0",
"concurrently": "^5.2.0",
"cross-env": "^7.0.2",
"css-loader": "3.4.2",
"dotenv": "8.2.0",
"dotenv-expand": "5.1.0",
"electron-is-dev": "^1.2.0",
"eslint": "^6.6.0",
"eslint-config-react-app": "^5.2.1",
"eslint-loader": "3.0.3",
"eslint-plugin-flowtype": "4.6.0",
"eslint-plugin-import": "2.20.1",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "7.19.0",
"eslint-plugin-react-hooks": "^1.6.1",
"file-loader": "4.3.0",
"fs-extra": "^8.1.0",
"html-webpack-plugin": "4.0.0-beta.11",
"identity-obj-proxy": "3.0.0",
"jest": "24.9.0",
"jest-environment-jsdom-fourteen": "1.0.1",
"jest-resolve": "24.9.0",
"jest-watch-typeahead": "0.4.2",
"mini-css-extract-plugin": "0.9.0",
"node-sass": "^4.14.1",
"optimize-css-assets-webpack-plugin": "5.0.3",
"pnp-webpack-plugin": "1.6.4",
"postcss-flexbugs-fixes": "4.1.0",
"postcss-loader": "3.0.0",
"postcss-normalize": "8.0.1",
"postcss-preset-env": "6.7.0",
"postcss-safe-parser": "4.0.1",
"react": "^16.13.1",
"react-app-polyfill": "^1.0.6",
"react-bootstrap": "^1.3.0",
"react-dev-utils": "^10.2.1",
"react-dom": "^16.13.1",
"react-icons": "^3.10.0",
"react-router-dom": "^5.2.0",
"react-scripts": "^3.4.1",
"resolve": "1.15.0",
"resolve-url-loader": "3.1.1",
"sass-loader": "8.0.2",
"semver": "6.3.0",
"shelljs": "^0.8.4",
"sqlite3": "^5.0.0",
"style-loader": "0.23.1",
"terser-webpack-plugin": "2.3.5",
"ts-pnp": "1.1.6",
"url-loader": "2.3.0",
"wait-on": "^5.0.0",
"webpack": "4.42.0",
"webpack-dev-server": "3.10.3",
"webpack-manifest-plugin": "2.2.0",
"workbox-webpack-plugin": "4.3.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"build-electron": "mkdir build\\src > nul & robocopy src\\shared build\\src\\shared /s > nul & robocopy electron build\\electron /s > nul || exit 0",
"electron-dev": "concurrently \"cross-env BROWSER=none npm run start\" \"wait-on http://localhost:3000 && electron .\"",
"eject": "react-scripts eject",
"electron-pack": "electron-builder -c.extraMetadata.main=build/electron.js",
"preelectron-pack": "npm run build"
},
"build": {
"appId": "com.icom.icomuav",
"files": [
"build/**/*",
"node_modules/**/*"
],
"directories": {
"buildResources": "assets"
}
},
"main": "public/electron.js",
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"style-loader": "^1.2.1",
"electron": "^8.2.5",
"electron-builder": "^22.6.0"
},
"jest": {
"roots": [
"<rootDir>/src"
],
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts"
],
"setupFiles": [
"react-app-polyfill/jsdom"
],
"setupFilesAfterEnv": [
"<rootDir>/src/setupTests.js"
],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
"<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
],
"testEnvironment": "jest-environment-jsdom-fourteen",
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
"^.+\\.module\\.(css|sass|scss)$"
],
"modulePaths": [],
"moduleNameMapper": {
"^react-native$": "react-native-web",
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"web.js",
"js",
"web.ts",
"ts",
"web.tsx",
"tsx",
"json",
"web.jsx",
"jsx",
"node"
],
"watchPlugins": [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname"
]
},
"babel": {
"presets": [
"react-app"
]
}
}
Basically this are the order which I run the scripts to package the whole thing.
build
build-electron
electron-pack
Any help would be appreciated. Thanks!
I know that I'm late to this, but I spent days tracking this issue down.
I ran npm run build first to package my react application so that i would actually have a build folder.
In my case, after using electron-forge to package my application, inside index.html all of my local imports to my .js files were missing the '.' before "/static/js/etc.js".
example:
example 2:
once changing it to the correct one as shown, it loaded everything just fine:
I really hope this helps someone.
I would suggest you to log the current route to the console, so you can see what page is loaded when you open both the development and the production build.
It might be caused by the router. In your project you probably have only 1 real HTML page - index.html, so make sure it loads /index.html and not /index.html/# (hash mode) or something.
Also try to add this event listener in your main process:
// Replace YOUR_WINDOW and modify the line that loads the URL
// (the same way you load URL when the window is created)
YOUR_WINDOW.webContents.on('did-fail-load', () => {
if (process.env.NODE_ENV === 'production') {
YOUR_WINDOW.loadURL('app://./index.html')
}
})
This can be fixed with chrome settings.
Please try to uncheck maps settings in Developer Tools Settings, and then refresh chrome.
uncheck Enable JavaScript source maps
uncheck Enable CSS source maps

ESLint configuration with react-scripts not working

I want to configure eslint as a precommit hook and my project is made using create-react-app. I have the following configuration with me currently. But with the following Lint staged is not running before commits. Also, I cannot install any other version of ESLint as react-scripts requires eslint with version 5.6.0 and it throws an error if I try to manually install some other version of it. What could be the issue here?
{
"name": "poc",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.18.0",
"babel": "^6.23.0",
"babel-core": "^6.9.1",
"babel-env": "^2.4.1",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.9.0",
"file-saver": "^2.0.2",
"identity-obj-proxy": "^3.0.0",
"jest-css-modules": "^2.0.0",
"joi": "^14.3.1",
"js-cookie": "^2.2.1",
"jwt-decode": "^2.2.0",
"material-ui": "0.20.1",
"node-sass": "^4.14.1",
"randomstring": "^1.1.5",
"react": "^16.5.2",
"react-appinsights": "^2.0.2",
"react-dom": "^16.5.2",
"react-drag-listview": "^0.1.4",
"react-loader-spinner": "^2.3.0",
"react-minimal-pie-chart": "^8.0.1",
"react-picky": "^4.4.5",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
"react-scripts": "2.1.1",
"react-select": "^3.0.4",
"xlsx": "^0.15.1"
},
"scripts": {
"start": "./node_modules/react-app-rewired/bin/index.js start",
"dev": "./node_modules/react-app-rewired/bin/index.js start",
"sbx": "./node_modules/react-app-rewired/bin/index.js start",
"stage": "./node_modules/react-app-rewired/bin/index.js start",
"prod": "./node_modules/react-app-rewired/bin/index.js start",
"build": "./node_modules/react-app-rewired/bin/index.js build",
"test": "jest",
"eject": "react-scripts eject",
"lint-staged": "lint-staged",
"lint": "react-scripts run lint"
},
"eslintConfig": {
"extends": [
"react-app",
"airbnb",
"prettier"
],
"rules": {
"semi": [
"error",
"always"
],
"indent": 2,
"no-console": "error",
"no-var": "error",
"import/prefer-default-export": "off"
},
"overrides": [
{
"files": [
"**/*.test.js",
"**/*.test.jsx"
],
"env": {
"jest": true
}
}
]
},
"husky": {
"hooks": {
"pre-commit": "echo aayushi && lint-staged"
}
},
"lint-staged": {
"*.{js,ts,tsx}": [
"prettier --write",
"lint"
],
"*.{json,md,html}": [
"prettier --write"
]
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"#babel/cli": "^7.4.4",
"#babel/core": "^7.4.4",
"#babel/plugin-transform-block-scoped-functions": "^7.2.0",
"#babel/plugin-transform-block-scoping": "^7.4.4",
"#babel/plugin-transform-classes": "^7.4.4",
"#babel/plugin-transform-computed-properties": "^7.2.0",
"#babel/plugin-transform-destructuring": "^7.4.4",
"#babel/plugin-transform-duplicate-keys": "^7.2.0",
"#babel/plugin-transform-for-of": "^7.4.4",
"#babel/plugin-transform-function-name": "^7.4.4",
"#babel/plugin-transform-instanceof": "^7.2.0",
"#babel/plugin-transform-literals": "^7.2.0",
"#babel/plugin-transform-new-target": "^7.4.4",
"#babel/plugin-transform-object-super": "^7.2.0",
"#babel/plugin-transform-parameters": "^7.4.4",
"#babel/plugin-transform-react-jsx-self": "^7.10.1",
"#babel/plugin-transform-react-jsx-source": "^7.10.1",
"#babel/plugin-transform-shorthand-properties": "^7.2.0",
"#babel/plugin-transform-spread": "^7.2.2",
"#babel/plugin-transform-sticky-regex": "^7.2.0",
"#babel/plugin-transform-template-literals": "^7.4.4",
"#babel/plugin-transform-typeof-symbol": "^7.2.0",
"#babel/plugin-transform-unicode-regex": "^7.4.4",
"#babel/preset-env": "^7.4.4",
"applicationinsights": "^1.0.8",
"babel-plugin-transform-es2015-arrow-functions": "^6.22.0",
"cookie-parser": "^1.4.3",
"ejs": "^2.6.1",
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.13.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"express-session": "^1.15.6",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"html-loader": "^0.5.5",
"html-webpack-plugin": "^3.2.0",
"husky": "^4.3.0",
"jest": "^23.6.0",
"jest-transform-css": "^2.0.0",
"lint-staged": "^10.5.1",
"passport": "^0.4.0",
"passport-saml": "^1.0.0",
"powerbi-report-component": "^1.1.3",
"prettier": "^2.2.0",
"react-app-rewired": "^2.1.3",
"workerize-loader": "^1.1.0"
},
"jest": {
"verbose": true,
"setupTestFrameworkScriptFile": "./src/test-setup.js",
"transform": {
"^.+\\.(js|jsx)?$": "babel-jest",
".+\\.(css|styl|less|sass|scss|svg)$": "jest-transform-css"
},
"transformIgnorePatterns": [
"node_modules/(?!(react-native|my-project|react-native-button)/)"
],
"moduleNameMapper": {
"my-module.js": "<rootDir>/path/to/my-module.js",
"\\.(css|less|sass|scss|svg)$": "identity-obj-proxy"
},
"collectCoverage": true,
"coverageReporters": [
"html",
"lcov",
"text"
]
}
}

Unable to use Jest: SyntaxError: Unexpected identifier at Runtime.createScriptFromCode

I just installed Jest with npm and now I'm trying to run some tests. Turns out I'm not able to do so since I get the following error:
● Test suite failed to run
C:\Users\aleja\Documents\FINAL PAW POSTA\paw-2018b-10\frontend\src\tests\PublicationService.test.js:3
import PublicationService from '../services/PublicationService'; // import * as StatusCode from '../util/StatusCode'
^^^^^^^^^^^^^^^^^^
SyntaxError: Unexpected identifier
at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1059:14)
And here's my package.json. I've read on other questions about babel.rc files and stuff but I don't even have those files.
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"#babel/preset-react": "^7.7.4",
"#material-ui/core": "^4.8.2",
"#material-ui/icons": "^4.5.0",
"#material/react-linear-progress": "^0.15.0",
"axios": "^0.19.0",
"axios-mock-adapter": "^1.17.0",
"babel-jest": "^25.1.0",
"bootstrap": "^4.4.1",
"crypto-js": "^3.1.9-1",
"enzyme": "^3.11.0",
"formik": "^1.5.8",
"i18next": "^17.3.1",
"i18next-browser-languagedetector": "^3.1.1",
"i18next-xhr-backend": "^3.2.2",
"jest": "^25.1.0",
"mutex-promise": "^0.1.0",
"query-string": "^6.9.0",
"react": "^16.12.0",
"react-bootstrap": "^1.0.0-beta.16",
"react-bootstrap-switch": "^15.5.3",
"react-content-loader": "^4.3.4",
"react-dom": "^16.12.0",
"react-form-validator-core": "^0.6.4",
"react-geocode": "^0.2.1",
"react-google-maps": "^9.4.5",
"react-i18next": "^10.13.2",
"react-images-upload": "^1.2.7",
"react-images-viewer": "^1.6.2",
"react-material-ui-form-validator": "^2.0.9",
"react-notifications-component": "^2.2.4",
"react-paginate": "^6.3.2",
"react-router-dom": "^5.1.2",
"react-scripts": "^3.3.0",
"react-spring": "^8.0.27",
"react-toast-notifications": "^2.4.0",
"redux": "^4.0.5",
"toasted-notes": "^3.2.0",
"webfontloader": "^1.6.28",
"yup": "^0.27.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "jest",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"#babel/cli": "^7.1.2",
"#babel/core": "^7.1.2",
"#babel/preset-env": "^7.1.0",
"#babel/preset-react": "^7.0.0",
"#testing-library/jest-dom": "^5.0.2",
"#testing-library/react": "^9.4.0",
"babel-plugin-transform-es2015-modules-amd": "^6.24.1",
"grunt": "^1.0.4",
"grunt-babel": "^8.0.0",
"grunt-sass": "^3.1.0",
"grunt-war": "^0.5.1",
"node-sass": "^4.13.1",
"react-test-renderer": "^16.12.0",
"reactotron-react-js": "^3.3.7",
"sass": "^1.24.0"
},
"jest": {
"modulePaths": [
"node_modules"
],
"moduleFileExtensions": [
"js",
"jsx"
],
"moduleDirectories": [
"node_modules"
]
},
"homepage": "http://mypage.com/",
"proxy": "http://localhost:8080"
}
I've added some babel dependencies but the issue still doesn't get fixed.
I also added the "Jest" part in my package.json I read on another question. Still no luck.
Ok seems like I had to create a babel.config.js file in the root directory as it says here
module.exports = {
presets: [
[
'#babel/preset-env',
{
targets: {
node: 'current',
},
},
],
],
};

Resources