Proxy Errors
Im getting an error:
Proxy error: Could not proxy request /api/calendar/get-events?start=2022-05-28T23:00:00.000Z&end=2022-07-09T23:00:00.000Z from localhost:3000 to http://localhost:5000/.
See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNRESET).
Proxy error: Could not proxy request /api/calendar/get-events?start=2022-05-28T23:00:00.000Z&end=2022-07-09T23:00:00.000Z from localhost:3000 to http://localhost:5000/.
See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED).
Have tried searching the internet for fixes to no avail so far.
{
"name": "res-app",
"version": "0.1.0",
"private": true,
"proxy": {
"/api/*": {
"target": "http://localhost:3000",
"secure": false
}
},
"dependencies": {
"#fullcalendar/daygrid": "^5.11.0",
"#fullcalendar/react": "^5.11.1",
"#testing-library/jest-dom": "^5.16.4",
"#testing-library/react": "^13.3.0",
"#testing-library/user-event": "^13.5.0",
"axios": "^0.27.2",
"moment": "2.29.3",
"react": "^18.2.0",
"react-datetime": "^3.1.1",
"react-dom": "^18.2.0",
"react-modal": "^3.15.1",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"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"
]
}
}
Related
I am getting 404 errors loading my react js app Ive deployed through github pages. I added a custom domain and I was getting DNS errors but ive resolved them and Im still unable to load the page. Im not sure what Ive done wrong.
To deploy to github pages I ran : npm run deploy
Then I added my custom domain and resolved the errors by adding the github IP addresses to the A records as shown in the documentation :
185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153
The errors Im seeing in the console are all on the .js, .css and manifest.json files. And my DNS check has been successful, Im not sure how to find whats gone wrong.
My package.json looks like this:
{
"homepage": "http://CRJones7.github.io/learned",
"name": "learned",
"version": "0.1.0",
"private": true,
"dependencies": {
"#primer/octicons-react": "^17.9.0",
"#testing-library/jest-dom": "^5.16.5",
"#testing-library/react": "^13.4.0",
"#testing-library/user-event": "^13.5.0",
"bootstrap": "^5.2.3",
"jquery": "^3.6.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.4.4",
"react-scripts": "5.0.1",
"reactstrap": "^9.1.5",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"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": {
"gh-pages": "^4.0.0"
}
}
{
"homepage": "http://CRJones7.github.io/learned",
"name": "learned",
"version": "0.1.0",
"private": true,
"dependencies": {
"#primer/octicons-react": "^17.9.0",
"#testing-library/jest-dom": "^5.16.5",
"#testing-library/react": "^13.4.0",
"#testing-library/user-event": "^13.5.0",
"bootstrap": "^5.2.3",
"jquery": "^3.6.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.4.4",
"react-scripts": "5.0.1",
"reactstrap": "^9.1.5",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"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": {
"gh-pages": "^4.0.0"
}
}
My errors look like this:
I have setup proxy in react package.json but the request is being sent to client-server instead of backed API I am using axios to consume API
my package.json
{
"name": "front",
"version": "0.1.0",
"private": true,
"dependencies": {
"#material-ui/core": "^4.11.3",
"#material-ui/icons": "^4.11.2",
"#testing-library/jest-dom": "^5.16.4",
"#testing-library/react": "^13.3.0",
"#testing-library/user-event": "^13.5.0",
"axios": "^0.27.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"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"
]
},
"proxy": "http://localhost:8000/api"
}
sample request
useEffect(() => {
const fetchPost = async () => {
const response = await axios.get(
"posts/timeline"
);
};
fetchPost();
}, []);
the request URL in the network tab is http://localhost:3000/posts/timeline
if anyone has fixes please suggest them.
I used yarn add github:username/custom-module to add a custom module to my project. The module and its contents appears in my node_modules folder, but I'm unable to import anything from it.
I import it into my file like using import { Component } from "custom-module";, but TypeScript returns, "Module not found: Error: Can't resolve 'custom-module' in 'filepath...'".
My project's package.json:
{
"name": "project-name",
"version": "0.1.0",
"private": true,
"dependencies": {
"#ant-design/icons": "^4.7.0",
"#dnd-kit/core": "^4.0.2",
"#dnd-kit/sortable": "^5.1.0",
"#testing-library/jest-dom": "^5.11.4",
"#testing-library/react": "^11.1.0",
"#testing-library/user-event": "^12.1.10",
"#types/express": "^4.17.13",
"#types/lodash": "^4.14.176",
"#types/react": "^17.0.38",
"#types/react-dom": "^17.0.11",
"#types/react-router-dom": "^5.3.2",
"#types/styled-components": "^5.1.15",
"#types/ws": "^8.2.2",
"eslint-plugin-react-hooks": "^4.3.0",
"esm": "^3.2.25",
"express": "^4.17.2",
"mobx": "^6.3.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-quick-reactions": "github:username/custom-module",
"react-router-dom": "^5.2.0",
"react-scripts": "5.0.0",
"styled-components": "^5.2.3",
"typescript": "^4.4.4",
"web-vitals": "^1.0.1",
"ws": "^8.4.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"serve": "node -r esm src/backend/server.ts"
},
"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"
]
},
"proxy": "http://localhost:8080",
"devDependencies": {
"#typescript-eslint/eslint-plugin": "^5.9.1",
"#typescript-eslint/parser": "^5.9.1",
"eslint-plugin-react": "^7.28.0"
}
}
And the package.json from the module:
{
"name": "custom-module",
"version": "0.1.0",
"private": false,
"description": "A description.",
"license": "MIT",
"keywords": [
"react",
"react-component",
],
"homepage": "https://github.com/username/custom-module#readme",
"bugs": {
"url": "https://github.com/username/custom-module/issues"
},
"repository": "github:username/custom-module",
"peerDependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"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": {
"#types/react": "^17.0.39",
"typescript": "^4.5.5"
}
}
As Phil suggested in this comment, the custom-module package.json did not contain main, files, or directories. I had to import directly from "custom-module/file/path/Component".
I installed eslint and Prettier in my project and I'm trying to deploy it on heroku
but I still getting error ( failure deploy ).
Failed to compile.
Failed to load plugin 'prettier' declared in 'package.json': Cannot find module 'eslint-plugin-prettier'
Require stack:
- /tmp/build_e0cdc90b/client/node_modules/react-scripts/config/__placeholder__.js
Referenced from: /tmp/build_e0cdc90b/client/package.json
How can I solve this problem ?
package.json file
{
"name": "client",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:8080",
"dependencies": {
"#testing-library/jest-dom": "^5.14.1",
"#testing-library/react": "^11.2.7",
"#testing-library/user-event": "^12.8.3",
"antd": "^4.16.13",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^5.3.0",
"react-scripts": "4.0.3",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"plugin:prettier/recommended",
"prettier"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.26.1",
"prettier": "^2.4.1"
}
}
I'm trying to deploy an app on amplify but I get an error when running the command amplify publish :
Missing script: "build"
An error occurred during the publish operation: Unknown error occurred.
Did someone run into this error and can help?
I have attached a picture of the error on my terminal[![amply terminal error
]1
and also my package.json
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.11.4",
"#testing-library/react": "^11.1.0",
"#testing-library/user-event": "^12.1.10",
"axios": "^0.21.1",
"jsonwebtoken": "^8.5.1",
"react": "^17.0.2",
"react-chartjs-2": "^2.11.1",
"react-dom": "^17.0.2",
"react-icons": "^4.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"web-vitals": "^1.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"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"
]
},
"proxy": "http://localhost:5000"
}