When build express-react app, it shows error - javascript

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

Related

'.' is not recognized as a internal command (React Package.Json)

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"

Electron ERR_CONNECTION_REFUSED to localhost:3000 Since Build

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.

react-app-rewired not working with tailwind css

I have an ongoing React.js project with these react versions.
"react": "^17.0.2",
"react-scripts": "^4.0.3",
The project is running perfectly without any issues. I wanted to add tailwind CSS for some parts of my project. So I follow all the steps in this Official documentation guide
But tailwind is not working at all. I have noticed my npm start command is a bit different, that may be the reason. My start command is "start": "react-app-rewired start" Normally when you create project with create-react-app it "start": "react-scripts start" Is this the reason that tailwind is not working here? How can I fix this?
Any help!
Thanks in advance.
You can resolve it by creating the Tailwind build process manually.
Create a tailwind-setup.css inside src folder.
Edit your package.json script object to this:
"scripts": {
"tailwind":"npx tailwindcss -i ./src/tailwind-setup.css -o ./src/tailwind-output.css --watch",
"start": "react-app-rewired start & yarn run tailwind",
"build": "react-app-rewired build & yarn run tailwind",
"test": "react-app-rewired test & yarn run tailwind",
"eject": "react-scripts eject"
...
},
And import ./src/tailwind-output.css in your App.tsx.

How to run React.js app without react-scripts?

My React.js app was created with this command:
npx create-react-app my-app
Now how can I convert this script section in package.json to run the app without react-scripts?
"scripts": {
"start": "NODE_ENV=development node_modules/react-scripts/bin/react-scripts.js start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
Should it be something like:
node index.js
How do I convert each option in that scripts section?
Thanks
When you create a React app with npx create-react-app my-app you make your react app dependant of react-scripts.
If you no longer want to use this react-scripts who give you a lot of help you can follow this tutorial from the official documentation to eject yourself.
But you can't remove the dependency from an existing project, maybe you are considering to make a new one, and this tutorial will help you to achieve it !

React app didn't render correctly when I deployed it to github pages

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

Categories

Resources