I am trying to connect react with multiple proxy server
and got this error
error
When specified, "proxy" in package.json must be a string.
Instead, the type of "proxy" was "object".
Either remove "proxy" from package.json, or make it a string.
package.json
{
"proxy": [
"http://192.168.29.184:5000",
"http://192.168.1.5:5000",
"http://localhost:5000"
],
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
}
someone please explain how can I separate it
Related
My Create React App is compiling over and over. Aside the fact is shouldn't do that its also very distracting.
this is the output from the default npm run start
I'm guessing it's something to do with linting, ideas?
EDIT:
scripts requested:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint:check": "eslint . --max-warnings=0",
"lint:fix": "eslint . --fix --max-warnings=0",
"prettier:check": "prettier . --check",
"prettier:fix": "prettier . --write"
}
I cannot deploy my react project on github pages because the change that I did in my package json shows the error below:
I just added inside of Scripts: publicar
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"publicar": "npm run build && ./node_modules/bin/gh-pages -d build"
},
I'm using '.' because i need to access the node_modules that is located in a different place that my package json.
When I execute the command 'npm run publicar' shows me this error:
'.' is not recognized as a internal command
When I execute the 'npm run publicar' should not show me errors and should show 'published'
npm runs with node_modules/bin in its PATH. You should just be able to use gh-pages the same way you use react-scripts.
I would also advise using a pre-script instead of chaining commands
"prepublicar": "npm run build",
"publicar": "gh-pages -d build"
Im getting this error
npm ERR! missing script: start
when I try to run 'npm start' for this new react project I'm working on. I've looked around for a solution and saw some folks found success when they did something like this in their package.json file.
"scripts": {
"start": "node index.js"
}
I attempted replicating the above code but got the same error when I tried to run "npm start". Are there any other steps I can take to fix this error?
Default scripts for a react project in package.json:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
}
App is consist of Node.js and React. There is no database. Heroku local web works fine but deployment doesn't work properly. Deployment just has index.html. In short words, node and react doesn't work properly on deployment.
backend package.json
"engines": {
"node": "15.4.0",
"npm": "7.20.5"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js",
"heroku-postbuild": "cd frontend && npm install && npm run build"
}
frontend package.json
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:5000"
app.js
app.use(express.static(path.join(__dirname, './frontend/build')));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname+'/frontend/build/index.html'));
});
const PORT = process.env.PORT || 5000;
Procfile
web: node app.js
Everything is fine with the heroku local web code as above. But on deployment I met error like this:
error I got
Stopping all processes with SIGTERM
heroku[web.1]: Process exited with status 143
I tried some solutions in here. But I couldn't solve.
I can write more information as needed. Thanks!
Add these to your frontend package.json scripts :
"devStart": "react-scripts start",
"start": "serve -s build",
....
"heroku-postbuild": "npm run build"
I have configured to run tests before commit. But it only works in Ubuntu.
Here what I have now:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"test:all": "CI=true react-scripts test"
},
"husky": {
"hooks": {
"pre-commit": "npm run test:all"
}
},
How to set cross env variables to run them in any operating system?
Use the cross-env package:
"test:all": "cross-env CI=true react-scripts test"
have you tried with a .env.test file? See React docs for info on .env in create-react-app create-react-app adding custom variables