3

I am trying to deploy a react project but did not use create-react-app to start the project i used a site called createapp.dev so i don't know if that is the issue. i included my package.json and an image of the error is as follows "Error"

    "scripts": {
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build",
    "clean": "rm dist/bundle.js",
    "start": "react-scripts start",
    "build-prod": "parcel build src/index.html"
  },
  "dependencies": {
    "node-sass": "^7.0.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-router-dom": "^6.3.0"
  },
  "devDependencies": {
    "@babel/core": "^7.18.5",
    "@babel/preset-env": "^7.18.2",
    "@babel/preset-react": "^7.17.12",
    "gh-pages": "^4.0.0",
    "parcel-bundler": "^1.12.5",
    "prettier": "^2.7.1"
  }
}
2
  • Where did those scripts come from? Unfortunately if that build script is missing, it may be a bug with the site you used. Commented Jul 8, 2022 at 23:34
  • Createapp.dev Commented Jul 8, 2022 at 23:54

3 Answers 3

3

You don't have a script called "build" in your package.json. Try with "build-prod" instead!

Sign up to request clarification or add additional context in comments.

3 Comments

Better than my answer, and probably correct. It's almost certainly a bug in the site OP used to generate the package.json.
it builds with "build-prod" but when i try to deploy the error still comes up
It still pops up because predeploy is calling the script called build, try changing "npm run build" to "npm run build-prod" in predeploy and see if it works
1

npm run build means to run the script called build from that list you provided. Your list doesn't have a script called build, so it fails.

3 Comments

I'm sorry the issue is with this createapp.dev you use "npm run build-prod" instead of "npm run build" but after it builds and i try to deploy it the error still comes up
Why are you using that site over something like create-react-app? It seems to not be worth the headaches. It does look pretty cool though.
i'm new to react so i decided to try it out 😪. but when i used create-react-app after all the headaches and copied the codes there a bunch of errors came up
0

Your script is not having build command specified that's the reason npm run build will fail.

Following are the observation from your package.json scripts:

"scripts": {
    "predeploy": "npm run build", // will run the code before deploy
    "deploy": "gh-pages -d build", // gh-pages => github pages hence this is for github deployment
    "clean": "rm dist/bundle.js", // rm to remove the bundle.js
    "start": "react-scripts start", // to start the react-app
    "build-prod": "parcel build src/index.html" // to make build using parcel module bundler
  }

Typically create-react-app uses Webpack as it's module bundler and here it's using Parcel. Depending on bundler there are different functionality and syntax as well as approach for the code from start to end.

As defined in your package.json instead of npm run build try npm run build-prod this will create build with parcel for src/index.html as root.

Generally npm run build will run the following react-scripts build you can try adding following into the scripts but I doubt it will work as build need to be created based on the module bundler used. You can give it a shot by adding following into scripts.

"build": "react-scripts build",

If it makes proper build with proper module bundler rules then it will run or else it will keep throwing errors.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.