Could start my react application using npm start - reactjs

I have created the react application using npx create-react-app task-tracker and this is my package.json file when ever I run npm start it shows error. As I am new to React I hardly have any knowledge about it.
this the error:
npm ERR! missing script: start
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ASUS\AppData\Roaming\npm-cache\_logs\2021-04-19T15_13_05_651Z-debug.log
package.json:
{
"name": "task-tracker",
"version": "0.1.0",
"private": true,
"dependencies": {
"cra-template": "1.1.2",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-scripts": "4.0.3"
}
}

It seems like create-react-app did not add the "scripts" field to the package.json object. I would try adding this field to package.json
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
}
If that doesn't work, try running create-react-app again

Related

How to solve npm missing script: Build and host my react application?

I am trying to host my react application with Netlify but when I run npm run build I have this error
npm ERR! missing script: build
This is my package.json file
"name": "client",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:5000",
"dependencies": {
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.5.0",
"#testing-library/user-event": "^7.2.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
}
How can I solve it ?
When Netlify runs npm, it is unable to find the run command in your package.json, most likely because it is in the wrong directory.
Your package.json needs to be in the Base directory in your Netlify config.

'react' - After run npm start it gives ./src/index.js Module not found: Can't resolve 'react' in 'C:\Users\...\src' error

In reactJs after run
npm start
it gives
./src/index.js Module not found: Can't resolve 'react' in
'C:\Users...\src'
error.
this is my package.js
{
"name": "client-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"#aspnet/signalr": "^1.0.4",
"react": "^16.5.2",
"react-dom": "^16.5.2",
"react-scripts": "^1.1.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
Try removing package-lock.json, run npm install and then run npm start again.

github pages displaying readme, not index.js

I have a basic React app. No backend. I want to set it up on github pages. I followed this article, twice. https://medium.freecodecamp.org/surge-vs-github-pages-deploying-a-create-react-app-project-c0ecbf317089
Both times, Github Pages displays the README.md file instead of the index.html file in my public folder. Here is an image of the file directory for the app. Any thoughts?
Here is what I have in package.json if it matters:
{
"name": "react-blog",
"version": "0.1.0",
"private": true,
"homepage": "https://jackseabolt.github.io/react-blog/",
"dependencies": {
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-scripts": "1.0.14"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy" : "npm run build&&gh-pages -d build"
},
"devDependencies": {
"gh-pages": "^1.0.0"
}
}
Your issue is likely that you are using your master branch as the source. In the settings tab on your Github project page, change the source to use the gh-pages branch.
See https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#step-4-ensure-your-projects-settings-use-gh-pages

"Module not found" when deploying React app to Heroku

When I try to deploy my React app (made with create-react-app) to Heroku (using create-react-app-buildpack) I get the following error:
Failed to compile.
Module not found: Error: Can't resolve 'jquery' in
'/tmp/build_049d73accaf035b451adf36ac44318d3/src/components'
npm ERR! Linux 3.13.0-128-generic
npm ERR! argv
"/tmp/build_049d73accaf035b451adf36ac44318d3/.heroku/node/bin/node"
"/tmp/build_049d73accaf035b451adf36ac44318d3/.heroku/node/bin/npm" "run"
"build"
npm ERR! node v6.11.2
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! life-quality-data#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
When testing on my computer everything works. I also have jQuery added as a dependency in package.json:
{
"name": "life-quality-data",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.16.2",
"dns": "^0.2.2",
"fetch": "^1.1.0",
"jquery": "^3.2.1",
"node-sass-chokidar": "0.0.3",
"numeral": "^2.0.6",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-router-dom": "^4.2.2",
"react-scripts": "1.0.12",
"xml2js": "^0.4.19"
},
"scripts": {
"build-css": "node-sass-chokidar src/ -o src/",
"watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
I think I might be missing a line. Also, could it be the .gitignore? Because on GitHub the node modules are being ignored.

Reactjs PEERINVALID eslint-plugin-jsx-a11y

I am trying to run example code for React Stock chart
https://github.com/rrag/react-stockcharts
The examples are in
https://github.com/rrag/react-stockcharts-examples2
I am new to npm and js and I want to run some examples to learn.
I got correct npm version and node js version but still I got some problem.
npm ERR! peerinvalid The package eslint-plugin-jsx-a11y#5.0.1 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer eslint-config-react-app#1.0.5 wants eslint-plugin-jsx-a11y#^5.0.3
I looked at package-lock.json and changed eslint-plugin-jsx-a11y#5.0.1 to 5.0.3 and still no luck.
Also, this is how package.json looks like.
{
"name": "react-stockcharts-example",
"description": "",
"version": "0.0.24",
"dependencies": {
"d3-dsv": "1.0.5",
"d3-format": "^1.2.0",
"d3-scale": "1.0.6",
"d3-time-format": "2.0.5",
"prop-types": "15.5.10",
"react": "15.5.3",
"react-dom": "15.5.3",
"react-stockcharts": "0.7.0-beta.12"
},
"devDependencies": {
"react-scripts": "1.0.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
Thank you for your help.

Resources