I have a React App that uses webpack and Cypress E2E testing. I'm trying to use Cypress component testing. I have written a simple test as follows:
describe('Hello World Test', () => {
it ('Button', () => {
mount(<Button>Test button</Button>)
cy.get('button').contains('Test button').click()
})
});
When I run npx cypress open-ct I get the following error:
Your pluginsFile threw an error from: .../experimentation/webpack-transition/cypress/plugins/index.js
Error: Cannot find module 'react-scripts/package.json'
When I look in to my node_modules folder that file does not exist under
#cypress/react/plugins/react-scripts/package.json (DNE)
cypress.json is as follows:
{
"baseUrl": "http://localhost:8080",
"component": {
"componentFolder": "src",
"testFiles": "**/*spec.{js,jsx,ts,tsx}"
}
}
package.json is as follows:
{
"name": "webpack-transition",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"bundle": "webpack",
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack-dev-server --env ENV=dev --mode development --open --hot",
"build": "webpack ---env ENV=dev --mode production"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"#babel/core": "^7.17.5",
"#babel/plugin-proposal-class-properties": "^7.16.7",
"#babel/plugin-proposal-object-rest-spread": "^7.17.3",
"#babel/preset-env": "^7.16.11",
"#babel/preset-react": "^7.16.7",
"#babel/preset-typescript": "^7.16.7",
"#types/react": "^17.0.40",
"#types/react-dom": "^17.0.13",
"awesome-typescript-loader": "^5.2.1",
"babel-loader": "^8.2.3",
"css-loader": "^6.7.1",
"cypress": "^9.5.1",
"dotenv-webpack": "^7.1.0",
"html-webpack-plugin": "^5.5.0",
"mini-css-extract-plugin": "^2.6.0",
"source-map-loader": "^3.0.1",
"style-loader": "^3.3.1",
"typescript": "^4.6.2",
"webpack": "^5.70.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.7.4"
},
"dependencies": {
"#cypress/react": "^5.12.4",
"#cypress/webpack-dev-server": "^1.8.2",
"#emotion/react": "^11.8.2",
"#emotion/styled": "^11.8.1",
"#hookform/resolvers": "^2.8.8",
"#mui/icons-material": "^5.5.0",
"#mui/lab": "^5.0.0-alpha.72",
"#mui/material": "^5.5.0",
"#reduxjs/toolkit": "^1.8.0",
"aws-amplify": "^4.3.16",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-hook-form": "^7.28.0",
"react-icons": "^4.3.1",
"react-redux": "^7.2.6",
"yup": "^0.32.11"
}
}
webpack.config is as follows:
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const Dotenv = require('dotenv-webpack');
module.exports = (env) => ({
entry: './src/components/index.tsx',
output: {
path: path.join(__dirname, '/dist'),
filename: 'bundle.js',
publicPath: '/'
},
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
module: {
rules: [
{
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
},
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.(png|svg|jpg|jpeg|gif|ico)$/,
exclude: /node_modules/,
use: ['file-loader?name=[name].[ext]']
}
]
},
devServer: {
historyApiFallback: true,
},
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html',
favicon: './public/favicon.ico'
}),
new MiniCssExtractPlugin({
filename: './src/index.css',
}),
new Dotenv({
path: `./.env.${env.ENV}`
}),
]
});
I'm either using the wrong version of a library or I'm missing a configuration somewhere.
It looks like you configured /cypress/plugins/index.js for Create React App (CRA) but have not use it to create your react app.
From the docs Install
React (using CRA)
// cypress/plugins/index.js
module.exports = (on, config) => {
if (config.testingType === 'component') {
require('#cypress/react/plugins/react-scripts')(on, config)
}
return config
}
Instead try the Generic Webpack configuration
// cypress/plugins/index.js
module.exports = (on, config) => {
if (config.testingType === 'component') {
const { startDevServer } = require('#cypress/webpack-dev-server')
// Your project's Webpack configuration
const webpackConfig = require('../../webpack.config.js')
on('dev-server:start', (options) =>
startDevServer({ options, webpackConfig })
)
}
}
Related
When I change the TS file, Webpack doesn't stop refreshing the page.
Console says: #ebpack 5.66.0 compiled successfully
I've googled this and tried different plugins, but they didn't work.
The mild refresh plugin just stopping the refresh and excluding JS files from ts-loader doesn't work at all.
The related issue in git didn't give the result as well.
webpack.config.json:
const webpack = require('webpack');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebPackPlugin = require("html-webpack-plugin");
const HTMLInlineCSSWebpackPlugin = require("html-inline-css-webpack-plugin").default;
const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin');
const htmlWebpackPlugin = new HtmlWebPackPlugin({
template: "./src/index.html",
filename: "./index.html",
inlineSource: '.(js|css)$',
inject: 'body',
});
module.exports = {
entry: ['./src/index.tsx', './src/main.css'],
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
fallback: {
"path": require.resolve("path-browserify"),
"os": require.resolve("os-browserify/browser"),
"url": require.resolve("url"),
"tty": require.resolve("tty-browserify"),
"minimatch": require.resolve("minimatch"),
"process": require.resolve("process")
},
},
module: {
rules: [{
test: /\.tsx?$/,
exclude: [/node_modules/, /\.js$/, /\.d\.ts$/, /dist/],
loader: 'ts-loader',
options: {
configFile: 'tsconfig.json',
}
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader"
]
}
],
},
output: {
filename: 'bundle.js',
publicPath: '',
},
plugins: [
new webpack.ProvidePlugin({
process: 'process',
}),
new MiniCssExtractPlugin({
filename: "main.css",
chunkFilename: "mainc.css"
}),
htmlWebpackPlugin,
new HTMLInlineCSSWebpackPlugin(),
new InlineChunkHtmlPlugin(HtmlWebPackPlugin, [/bundle/]),
]
};
package.json:
{
"name": "browser",
"version": "0.0.0",
"scripts": {
"build": "webpack --mode development",
"start": "webpack serve --mode development --port 3000"
},
"devDependencies": {
"#types/chrome": "^0.0.163",
"#types/jquery": "^3.5.10",
"#types/node": "^16.11.7",
"#types/react": "^17.0.34",
"#types/react-dom": "^17.0.11",
"#types/vscode": "^1.62.0",
"#types/vscode-webview": "^1.57.0",
"css-loader": "^6.5.1",
"html-inline-css-webpack-plugin": "^1.11.1",
"html-webpack-plugin": "^5.5.0",
"mini-css-extract-plugin": "^2.4.6",
"react-dev-utils": "^12.0.0",
"ts-loader": "^9.2.6",
"typescript": "^4.5.4",
"webpack": "^5.66.0",
"webpack-cli": "^4.9.1",
"webpack-dev-server": "^4.7.3"
},
"dependencies": {
"ace-builds": "^1.4.13",
"axios": "^0.24.0",
"bootstrap": "^5.1.3",
"jquery": "^3.6.0",
"minimatch": "^5.0.1",
"mobx": "^6.3.6",
"mobx-react": "^7.2.1",
"os-browserify": "^0.3.0",
"path-browserify": "^1.0.1",
"process": "^0.11.10",
"react": "^17.0.2",
"react-ace": "^9.5.0",
"react-bootstrap": "^2.0.2",
"react-dom": "^17.0.2",
"redoc": "^2.0.0-rc.66",
"styled-components": "^5.3.5",
"tty-browserify": "0.0.1",
"url": "^0.11.0",
"uuid": "^8.3.2"
}
}
You better change InlineChunkHtmlPlugin tests from /bundle/ to /runtime/.
Replace
new InlineChunkHtmlPlugin(HtmlWebPackPlugin, [/bundle/])
With
new InlineChunkHtmlPlugin(HtmlWebPackPlugin, [/runtime~.+[.]tsx/])
OR
new InlineChunkHtmlPlugin(HtmlWebPackPlugin, [/runtime/])
I am getting the below error while running the command npm run dev. But the same code is working fine in my colleague system. I am not getting what went wrong.
When I am adding one global.scss file in App.js then only I am getting the below error otherwise component level scss file working fine.
ERROR in ./src/client/styles/global.scss (./node_modules/css-loader/dist/cjs.js??ref--5-1!./node_modules/sass-loader/dist/cjs.js!./src/client/styles/global.scss)
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Invalid CSS after "��": expected "{", was ""
on line 1 of C:\Users\Azad\Repos\travelBookingCloud-FE\src\client\styles\global.scss
>> ��
^
# ./src/client/styles/global.scss 2:26-153 43:4-64:5 46:18-145
# ./src/client/client.js
i 「wdm」: Failed to compile.
webpack.config.js
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const Dotenv = require('dotenv-webpack');
const miniCssPlugin = new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css"
});
const htmlPlugin = new HtmlWebpackPlugin({
filename: "index.html",
template: path.join(__dirname, "src", "index.html")
});
const uglifyJsPlugin = new UglifyJsPlugin({
sourceMap: true,
test: /\.min\.js$/i,
});
const dotEnv=new Dotenv();
module.exports = (env, argv)=> {
const isDevelopment = argv.mode === 'development';
return {
optimization: {
nodeEnv: argv.mode
},
entry: path.join(__dirname, "src/client", "client.js"),
output: {
path: path.join(__dirname, "build"),
filename: "bundle.js",
publicPath: '/'
},
mode: argv.mode,
devtool: isDevelopment
? '#eval-source-map'
: 'source-map',
devServer: {
stats: {
children: false,
maxModules: 0
},
port: 3000,
historyApiFallback: true
},
node: {
fs: "empty"
},
resolve: {
modules: ['src/scripts', 'node_modules'],
extensions: ['.jsx', '.js'],
unsafeCache: true,
alias: {
Config: path.resolve(__dirname, 'src/config'),
Components: path.resolve(__dirname, 'src/client/components'),
Constants: path.resolve(__dirname, 'src/client/constants'),
Helpers: path.resolve(__dirname, 'src/client/helpers'),
Views: path.resolve(__dirname, 'src/client/views'),
Widgets: path.resolve(__dirname, 'src/client/widgets'),
App: path.resolve(__dirname, 'src')
}
},
module: {
rules: [
{
test: /.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
},
{
test: /\.(sa|sc|c)ss$/,
use: [
isDevelopment
? "style-loader"
: MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
importLoaders: 1
}
},
"sass-loader"
]
},
{
test: /\.(png|jpg|jp(e)g|gif|svg)$/i,
use: [
{
loader: "url-loader",
options: {
limit: 8192
}
}
]
},
{
test: /\.(ttf|eot|svg|jpg|jp(e)g|png|woff(2)?)(\?[a-z0-9=&.]+)?$/,
use: [
{
loader: "file-loader",
options: {
name: "[path][name]-[hash:8].[ext]"
}
}
]
}
]
},
plugins: [
uglifyJsPlugin,htmlPlugin,miniCssPlugin,dotEnv
]
};
};
package.json
{
"name": "travelbookingcloud-fe",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack --mode development",
"dev": "webpack-dev-server --mode development --hot --open",
"build": "webpack --mode production"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"#babel/core": "^7.10.4",
"#babel/plugin-proposal-class-properties": "^7.10.4",
"#babel/preset-env": "^7.10.4",
"#babel/preset-react": "^7.10.4",
"#date-io/date-fns": "^2.6.2",
"#material-ui/core": "^4.11.0",
"#material-ui/icons": "^4.9.1",
"#material-ui/lab": "^4.0.0-alpha.56",
"#material-ui/pickers": "^3.2.10",
"#material-ui/utils": "^4.10.2",
"axios": "^0.19.2",
"babel-loader": "^8.1.0",
"copy-webpack-plugin": "^6.0.3",
"css-loader": "^3.6.0",
"dotenv": "^8.2.0",
"dotenv-webpack": "^1.8.0",
"file-loader": "^6.0.0",
"html-webpack-plugin": "^4.3.0",
"mini-css-extract-plugin": "^0.9.0",
"moment": "^2.27.0",
"node-sass": "^4.14.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-router-dom": "^5.2.0",
"sass-loader": "^8.0.2",
"style-loader": "^1.2.1",
"uglifyjs-webpack-plugin": "^2.2.0",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0"
},
"dependencies": {
"react-redux": "^7.2.0",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0"
}
}
I've been trying to use both Formik and React-Form-Hooks but both libraries throw the same error when compiled. I use Typescript as my language and Babel as transpiler.
Uncaught TypeError: Object(...) is not a function
which occurs at:
const FormGlobalContext = Object(react__WEBPACK_IMPORTED_MODULE_0__["createContext"])(null);
with Formik having FormikContext. I haven't done anything except import both of them (seperately), so I have no code to show.
package.json:
{
"name": "x",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"watch": "babel --watch src --out-dir dist --extensions .ts,.tsx",
"build": "webpack --mode development",
"tsc": "tsc"
},
"devDependencies": {
"#babel/cli": "^7.7.5",
"#babel/core": "^7.7.5",
"#babel/plugin-proposal-class-properties": "^7.7.4",
"#babel/plugin-proposal-object-rest-spread": "^7.7.4",
"#babel/plugin-syntax-dynamic-import": "^7.7.4",
"#babel/preset-env": "^7.7.6",
"#babel/preset-typescript": "^7.7.4",
"#babel/plugin-proposal-async-generator-functions": "^7.7.4",
"#babel/plugin-transform-async-to-generator": "^7.7.4",
"#babel/plugin-transform-regenerator": "^7.7.5",
"#babel/polyfill": "^7.7.0",
"#babel/preset-react": "^7.7.4",
"#types/jquery": "^3.3.31",
"#types/lodash": "^4.14.149",
"#types/react": "^16.9.17",
"#types/react-dom": "^16.9.4",
"#types/underscore": "^1.9.4",
"#types/yup": "^0.26.27",
"#types/delaunator": "^3.0.0",
"awesome-typescript-loader": "^5.2.1",
"babel-loader": "^8.0.6",
"babel-minify-webpack-plugin": "^0.3.1",
"react-hot-loader": "^4.12.18",
"typescript": "^3.7.3",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10",
"babel-polyfill": "^6.26.0",
"uglifyjs-webpack-plugin": "^2.2.0",
"underscore": "^1.9.1"
},
"author": "",
"license": "ISC",
"dependencies": {
"jquery": "^3.4.1",
"lodash": "^4.17.15",
"moment": "^2.24.0",
"react": "^15.1.1",
"react-dom": "^15.1.1",
"react-hook-form": "^3.29.4",
"yup": "^0.28.0"
}
}
.babelrc
{
"presets": [
["#babel/env", { "modules": false }],
"#babel/preset-react",
"#babel/typescript"
],
"plugins": [
"#babel/plugin-syntax-dynamic-import",
"#babel/proposal-class-properties",
"#babel/proposal-object-rest-spread",
"#babel/plugin-transform-regenerator",
"#babel/plugin-proposal-async-generator-functions",
"#babel/plugin-transform-async-to-generator"
]
}
webpack.config.js:
const path = require('path');
const webpack = require('webpack');
const MinifyPlugin = require("babel-minify-webpack-plugin");
module.exports = {
watch: true,
entry: './src/index.ts',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'babel-loader',
exclude: /node_modules/,
sideEffects: true,
},
],
},
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
output: {
filename: 'tplanner.js',
path: path.resolve(__dirname, 'dist'),
libraryTarget: 'umd',
umdNamedDefine: true
},
plugins: [
new MinifyPlugin({}, {}),
new webpack.HotModuleReplacementPlugin()
]
};
My React and React-Dom were outdated, I used npm upgrade react react-dom to fix it.
I have 3 webpack.config files to enable Server-Sive-Rendering.
webpack.base.js
webpack.client.js
webpack.server.js
Build Script
"scripts": {
"dev": "npm-run-all --parallel dev:*",
"dev:bundle": "nodemon --watch build --exec \"node build/bundle.js\"",
"dev:server": "webpack --config webpack.server.js --watch",
"dev:client": "webpack --config webpack.client.js --watch"
}
I was struggling to setup css on SSR.
When I tried :
npm run dev:client -> It works with no error!
npm run dev:server -> It works with no error!
but,
npm run dev:bundle I got an error message.
Here is my webpack settings
webpack.base.js
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const devMode = process.env.NODE_ENV !== 'production';
module.exports = {
module: {
rules: [
{
test: /\.js?$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
presets: [
'react',
'stage-0',
['env', { target: { browsers: ['last 2 versions'] }}]
]
}
},
{
test: /\.(sa|sc|c)ss$/,
use: [
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader',
'sass-loader',
],
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: devMode ? '[name].css' : '[name].[hash].css',
chunkFilename: devMode ? '[id].css' : '[id].[hash].css',
})
]
};
webpack.client.js
const path = require('path');
const merge = require('webpack-merge');
const baseConfig = require('./webpack.base.js');
const config = {
mode: 'development',
//Tell webpack the root file of our
//server application
entry: './src/client/client.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'public')
}
};
module.exports = merge(baseConfig, config);
webpack.server.js
const path = require('path');
const merge = require('webpack-merge');
const baseConfig = require('./webpack.base.js');
const webpackNodeExternals = require('webpack-node-externals');
const config = {
//Inform webpack that we're building a bundle
//for nodeJS, rather than for the browser
mode: 'development',
target: 'node',
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'build')
},
externals: [webpackNodeExternals()]
};
module.exports = merge(baseConfig, config);
package.json
{
"name": "shawnbaek.com",
"version": "1.0.0",
"description": "Server-Side-Rendering Wordpress Site",
"main": "index.js",
"scripts": {
"dev": "npm-run-all --parallel dev:*",
"dev:bundle": "nodemon --watch build --exec \"node build/bundle.js\"",
"dev:server": "webpack --config webpack.server.js --watch",
"dev:client": "webpack --config webpack.client.js --watch"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ShawnBaek/shawnbaek.com.git"
},
"keywords": [
"wordpress"
],
"author": "Shawn Baek",
"license": "ISC",
"bugs": {
"url": "https://github.com/ShawnBaek/shawnbaek.com/issues"
},
"homepage": "https://github.com/ShawnBaek/shawnbaek.com#readme",
"dependencies": {
"autoprefixer": "^9.1.5",
"axios": "^0.18.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.4",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"clean-webpack-plugin": "^0.1.19",
"compression": "^1.7.2",
"concurrently": "^3.5.1",
"css-loader": "^1.0.0",
"express": "^4.16.3",
"express-http-proxy": "^1.2.0",
"html-webpack-plugin": "^3.2.0",
"lodash": "^4.17.10",
"mini-css-extract-plugin": "^0.4.3",
"node-sass": "^4.9.3",
"nodemon": "^1.17.4",
"npm-run-all": "^4.1.2",
"postcss": "^7.0.2",
"postcss-loader": "^3.0.0",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-helmet": "^5.2.0",
"react-redux": "^5.0.7",
"react-router-config": "^1.0.0-beta.4",
"react-router-dom": "^4.2.2",
"redux": "^4.0.0",
"redux-thunk": "^2.2.0",
"sass-loader": "^7.1.0",
"serialize-javascript": "^1.5.0",
"style-loader": "^0.23.0",
"tailwindcss": "^0.6.6",
"webpack": "^4.7.0",
"webpack-dev-server": "^3.1.4",
"webpack-merge": "^4.1.2",
"webpack-node-externals": "^1.7.2"
},
"devDependencies": {
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"webpack-cli": "^2.1.2"
}
}
add globalObject: 'this' within output block to fix this issue
Since im building my webapp with React, when i try to set something into an undefined object property, the code processing crashes (reproducible with breakpoint debugging) and no errors are shown in the console log. Also the chrome react extension does not give me any errors.
So to finding a bug is more time consuming that it should be.
let changedJsonResponse = jsonResponse;
changedJsonResponse.data = newTableData; // changedJsonResponse.data is undefined
// throws no error & code proccess crashes
webpack.config.js
const webpack = require('webpack');
const path = require('path');
let config = {
devtool: 'eval-source-map',
entry: {
FooManagement: ['babel-polyfill', './domains/FooManagement/entry.jsx'],
},
output: {
path: path.resolve(__dirname, '../web/react/'),
filename: '[name].js'
},
externals: {
'jquery': 'window.jQuery',
'bootbox': 'window.bootbox',
},
resolve: {
alias: {
alias_shared: path.resolve(__dirname, 'shared'),
},
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: [/node_modules/],
loader: 'babel-loader',
options: {presets: ['es2015', 'react']}
},
{
test: /\.css/,
loader: 'style-loader!css-loader'
}
]
}
};
module.exports = config;
package.json
{
"author": "myself",
"version": "0.0.1",
"description": "",
"main": "index.jsx",
"scripts": {
"watch": "webpack -d --watch",
"build": "webpack -p"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.7",
"style-loader": "^0.19.0",
"webpack": "^3.8.1"
},
"dependencies": {
"axios": "^0.16.2",
"dateformat": "^3.0.2",
"is-uuid": "^1.0.2",
"lodash": "^4.17.4",
"react": "^16.0.0",
"react-cropper": "^1.0.1",
"react-dom": "^16.0.0",
"react-dropzone": "^4.2.3",
"react-router-dom": "^4.2.2",
"react-switchery-component": "0.0.7",
"uuid": "^3.1.0"
}
}
Chrome version: 62.0.3202.94
I was able to catch those errors in Axios .catch.
After a while i found the cause of the problem.