lint-staged no stage files match - javascript

Used create-react-app template. Windows, OpenServer.
package.json
{
"name": "league-finder",
"version": "0.1.0",
"private": true,
"dependencies": {
"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",
"pre-commit": "lint-staged",
"eslint": "./node_modules/.bin/eslint src/"
},
"devDependencies": {
"eslint-config-prettier": "^3.1.0",
"eslint-plugin-prettier": "^2.7.0",
"husky": "^1.0.1",
"lint-staged": "^7.3.0",
"prettier": "^1.14.3"
}
}
.lintstagedrc
{
"*.js": ["eslint --fix", "git add"],
}
Result: screenshot
Why "No staged files match *.js"?

Related

How to build a react project without minify the node modules

I've been working on a project, but when I try to build it I got the following error:
Failed to minify the code from this file:
./node_modules/emailjs-com/es/utils/validateParams.js:1:7
I am using craco to build the project. I have researched about this error, but I was not able to make any of the solutions I found work on my case.
My package.json:
{
"name": "my-portfolio",
"version": "0.1.0",
"private": true,
"dependencies": {
"-": "^0.0.1",
"#craco/craco": "^5.9.0",
"#fortawesome/fontawesome-svg-core": "^1.2.35",
"#fortawesome/free-brands-svg-icons": "^5.15.3",
"#fortawesome/free-solid-svg-icons": "^5.15.3",
"#fortawesome/react-fontawesome": "^0.1.14",
"#heroicons/react": "^1.0.1",
"dotenv": "^10.0.0",
"emailjs": "^3.5.0",
"emailjs-com": "^3.2.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-helmet": "^6.1.0",
"react-icons": "^4.2.0",
"react-scripts": "^1.1.5",
"save-dev": "^0.0.1-security"
},
"scripts": {
"start": "craco start",
"build": "craco build",
"test": "craco test",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"devDependencies": {
"autoprefixer": "^9.8.6",
"gh-pages": "^3.2.3",
"postcss": "^7.0.36",
"tailwindcss": "npm:#tailwindcss/postcss7-compat#^2.0.2"
}
}
I would like to know if there is a way to build it without executing any minification, or if it is really required, how to solve the minification that I am having when trying to minify my code.

I am getting "Cannot use import statement outside a module" while trying to import firebase in react

I made the react app using create-react-app and installed firebase : 8.2.3, but while importing firebase in App.js I am getting error "Cannot use import statement outside a module" and my app doesn't run.
here are my package.json configuration:
{
"name": "sample-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"firebase": "^8.2.3",
"gh-pages": "^3.1.0",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-lazyload": "^3.1.0",
"react-lines-ellipsis": "^0.14.1",
"react-router-dom": "^5.2.0",
"react-scripts": "0.9.x",
"react-test-renderer": "^17.0.1",
"zustand": "^3.1.4"
},
"devDependencies": {},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
}
}

How to run node js and react?

My question is simple How to run a server node js and a react app in same time?
My package.json
{
"name": "mon-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"express": "^4.17.1",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-scripts": "0.9.5"
},
"devDependencies": {
"concurrently": "^2.2.0"
},
"scripts": {
"start": "concurrently \"node server.js\" \"react-scripts start\"",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
I use concurrently
Moreover npm start runs of course the dev server
Thanks for your help :)
you can try doing something like this:
{
"name": "mon-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"express": "^4.17.1",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-scripts": "0.9.5"
},
"devDependencies": {
"concurrently": "^2.2.0"
},
"scripts": {
"server": "node server.js",
"client": "react-scripts start",
"start": "concurrently \"npm run server\" \"npm run client\"",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
does that solve your problem?

React Webpack Utils Error

When running npm start I get this error
Cannot find module 'react-dev-utils/WebpackDevServerUtils'
I even tried deleting and reinstalling. Any help? Here's package.json
{
"name": "tic-tac-toe-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
"react-scripts": "1.1.4",
"webpack": "^4.15.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"devDependencies": {
"react-dev-utils": "^5.0.1",
"react-scripts": "^1.1.4",
"webpack": "^1.15.0",
"webpack-cli": "^3.0.8",
"webpack-command": "^0.4.1",
"webpack-dev-server": "^3.1.4"
}
}
Delete the "node_modules' folder within the project
Then run npm install again

Nodejs: unable to run expressjs and reactjs together

I use reactjs for frontend and expressjs for backend API.
I tried this
{
"name": "carweb",
"version": "0.1.0",
"private": true,
"dependencies": {
"async": "^2.5.0",
"body-parser": "^1.17.2",
"cors": "^2.8.4",
"crypto-js": "^3.1.9-1",
"dotenv": "^4.0.0",
"expressjs": "^1.0.1",
"jquery": "^3.2.1",
"jwt-simple": "^0.5.1",
"nodemon": "^1.11.0",
"react": "^15.6.1",
"react-countup": "^2.1.1",
"react-document-title": "^2.0.3",
"react-dom": "^15.6.1",
"react-materialize": "^1.0.6",
"react-rethinkdb": "^0.6.0",
"react-router-dom": "^4.1.2",
"react-scripts": "1.0.10",
"rethinkdb": "^2.3.3",
"spicy-datatable": "^0.4.0",
"web-storage": "^1.0.0"
},
"scripts": {
"start": "react-scripts start",
"backend": "nodemon ./src/js/backend/app.js",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
This work perfectly. So I want to combine both commands together.
I tried:
react-scripts start && nodemon ./src/js/backend/app.js
This is not working.
Try this npm package https://www.npmjs.com/package/concurrently
It'll allow you to do what you want. The question is "is this approach correct"

Categories