I've been working on a small app with React/Electron, and so far things are working out. Building it is a bit complicated for me. Ever since I've built this application, I can no longer run npm run dev to develop this app locally (localhost:3000), I get this error:
electron: Failed to load URL: http://localhost:3000/ with error: ERR_CONNECTION_REFUSED
I've checked with electron is dev and we are still currently in development.
My loadURL is fairly simple:
mainWindow.loadURL(isDev
? 'http://localhost:3000'
: `file://${path.join(__dirname, '../build/index.html')}`);
These are my package.json scripts:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"dev": "wait-on tcp:3000 && concurrently -k \"npm:electron\"",
"electron": "electron .",
"electron:package:mac": "yarn build && electron-builder -m -c.extraMetadata.main=build/electron.js",
"electron:package:win": "yarn build && electron-builder -w -c.extraMetadata.main=build/electron.js",
"electron:package:linux": "yarn build && electron-builder -l -c.extraMetadata.main=build/electron.js"
},
I read a thread on stackoverflow that mentioned to switch loadURL to the index in build folder, which it will load there but it doesn't show the updates I'm working on until I actually build the app.
I've also tried to kill-port 3000, and still getting the same issue.
Any help would be appreciated.
Thanks.
Related
Failed to migrate: buildpacks from Heroku to Nixpacks
I need help I can't do the migration of my front end projects it doesn't compile and gives an error.
My Heroku buildpacks:
This script works correctly to generate the application on Heroku and Vercel, but I can't install it with the Nixpacks package. Can someone tell me what is wrong with the scripts?
"scripts": {
"dev": "react-scripts start",
"start": "serve -s build",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"heroku-postbuild": "npm run build",
"install:clean": "rm -rf node_modules/ && rm -rf package-lock.json && npm install && npm start",
"compile:scss": "node-sass src/assets/scss/light-bootstrap-dashboard-react.scss src/assets/css/light-bootstrap-dashboard-react.css",
"minify:scss": "node-sass src/assets/scss/light-bootstrap-dashboard-react.scss src/assets/css/light-bootstrap-dashboard-react.min.css --output-style compressed",
"map:scss": "node-sass src/assets/scss/light-bootstrap-dashboard-react.scss src/assets/css/light-bootstrap-dashboard-react.css --source-map true",
"build:scss": "npm run compile:scss && npm run minify:scss && npm run map:scss"
},
Error:
Using Nixpacks
Nixpacks build failed
If someone could help me, so as not to leave the railway.
The Heroku buildpacks are finally leaving Railway forever on Novermber 14th.
Moving From Heroku to Railway
I really appreciate any help, I'm new to this type of development
In railway settings>general>root directory> name of the directory where you do mpn start
&&
package.json>"scripts">"start": "nodemon src/app.js"
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"
I currently working in a react - expressjs project which was worked by someone before.
Currently, when I'm trying to run the command
npm run build
The project shows me the following error:
What can I do with that error?
As an additional information (I don't know if that is related), when I try to deploy any change I do in the project it doesn't take it into account due as I understand, the deploy depends on chunk.js files (created by the build). I mean, chunk.js files are not been updated.
And in the configuretion of the deploy... the project specifies that I needs to point those chunk.js files
How can I change that configuration?
Here is my package.json file (the scripts section)
Thanks in advance
can you share your package.json Scripts ? there is a possibility you are missing the "build" Script
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
try to reinstall the dependencies again globally, check this link => reactgo.com/react-scripts-command-not-found and sh: react-scripts: command not found after running npm start
I try to deploy my react app to github pages, but it seems that it didn't work properly. I got a blank page when I tried to visit it by link. Anybody knows solutions? Thank you for your help!
My code is like:
package.json
"homepage": "https://yunxiuqiu1115.github.io/food-ordering-site",
"scripts": {
"start": "PORT=3006 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
I ran npm run deploy and get the successful outcome.
Everything works well locally, but does not work in github pages. Hope that anyone can help! Thanks!
We need to install GitHub Pages package as a dev-dependency.
cd **
npm install gh-pages --save-dev
Add properties to package.json file.
Follow this for more details https://dev.to/yuribenjamin/how-to-deploy-react-app-in-github-pages-2a1f
In my package.json I have run scripts that look like:
"scripts": {
"build:style":"tailwind build src/styles/index.css -o src/styles/tailwind.css",
"start": "npm run build:style && react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
I'm using this tailwindcss framework for CSS, and it uses PostCSS to update the CSS.
Currently if I update my CSS npm doesn't run the build, so my CSS changes are not visible until I stop and re-rerun:
npm run start
Is there a way for npm to watch the CSS files, and when changed also run the build:style command?
Unfortunately, I don't believe Tailwinds has a 'watch' feature. I believe one workaround would be to install the watch package.
npm install watch
You have a lot of scripts going on and without knowing how you've integrated PostCSS and the likes, it's tough to know exactly what to do. One option would be to create a new script that takes advantage of the new watch node package.
"scripts": {
"build:style":"tailwind build src/styles/index.css -o src/styles/tailwind.css",
"start": "npm run build:style && react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"watch": "watch 'npm run start'"
},
If that doesn't work, check out the blog below. It uses the same methodology, but may have insight that could help you figure it out!
https://flaviocopes.com/tailwind-setup/