Git hooks not generated - githooks

I am working on a project that has some git hooks setup using husky. I ran npm install and I can see that husky is installed but the hooks are not generated.
How can I generate the same?
PS I do not have any pre-existing hooks.
Any help would be appreciated.

You can manually trigger hook generation by using
node node_modules/husky/husky.js install
or
node node_modules/husky/bin/install.js for some older versions.
Ref: https://github.com/typicode/husky/issues/81

Related

Failed to load plugin 'flowtype' declared in 'package.json » eslint-config-react-app': Cannot find module 'eslint/use-at-your-own-risk'

I created a new React project with create-react-app.
In the terminal npm start.
Instantly get this error
Failed to load plugin 'flowtype' declared in 'package.json »
eslint-config-react-app': Cannot find module
'eslint/use-at-your-own-risk'
How do I fix this?
Not this project specifically, but how do I get create-react-app to create without errors?
I fix this just deleting:
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
}
on package.json
what's happening is that when you run npm start it's probably doing some checks with eslint, from what I remember create-react-app has some checks that break your build if you have eslint errors so makes sense that they're associated.
The error you're getting here is related to a node feature that eslint is using called subpath exports but it's support is hit or miss depending on how the library is consumed. This has been highlighted to cause issues when used with jest for example.
For the flowtype eslint plugin this is the exact line of code that's causing you issues.
You can also read about a similar issue reported regarding the typescript eslint plugin.
The solution and the reason I'm even able to understand what's causing this problem is that I made a fix to this yesterday in a clone of the eslint-plugin-flowtype (given that the original plugin had a lack of maintenance) here https://github.com/flow-typed/eslint-plugin-ft-flow/pull/23.
I'll raise an issue with create-react-app and see if they're willing to swap out the plugin with the new one which would have more maintenance and solve issues that you're experiencing.
i also had same problem. so In my case, I found my node version was v12. so i got to know CRA v5.x which should be with >= node v14.
so I switched to Node v16.10.0 and solved it.
I also found that I could resolve this issue by switching my node version to the LTS version.
I experienced this issue when running node version 12.13.0
Switching to version 16.14.2 resolves the issue for me.
I experienced the same problem in webstorm with react. My solution after reading some other peoples comments was to use Eslint version 7.32.0 i was originally using 6.8 which was causing the problems and now it works. I also read that version 8 or higher is not supported
If anyone is still having this problem currently I managed to solve this error for myself by deleting the node-modules folder and the package-lock.json file. and then running npm install. This is also with Node and create-react-app #latest version.
DISABLE_ESLINT_PLUGIN=true react-app-rewired start can avoid this error, and no need of ">= node v14" (even node10 can work), for only eslint#8 is using Module.createRequire, ref to doc Upgrade to react-scripts#5 and Add Web Workers support and APP PixelShapeRN commit Add Web Workers support for CRA v5 (and Webpack 5)
for me, upgrading my node version from 12.12.0 to 16.0.0 helped. old node version create this problem mostly.
Updating node version to v16 will resolve this issue.
Use nvm command or download latest version of node to install update node version.
Here is step if you want to use nvm
nvm install 16.16.0
This will install and update running node version
use this to switch back to any node version present in your system
nvm use v14.14.0
Note: You can follow steps given below to install NVM in you system.
For MAC: https://tecadmin.net/install-nvm-macos-with-homebrew/
For Windows: https://tecadmin.net/install-nodejs-with-nvm-on-windows/
try using newer version of node to run your app. I had 12 and tried 16 and it fixed the issue.

How to Yarn add a specific branch/workspace

I forked react-select to add a couple of features that the current react-select doesn't have. I created a branch and committed it to my forked project. Now, i want to use the forked project.
Ive tried installing the forked react-select repo the following ways with out success.
yarn add #react-select/monorepo#<GithubUsername>/react-select#head=<Name of branch>&workspace=react-select
yarn add #react-select/monorepo#<GithubUsername>/react-select#commit=<commit#>&workspace=react-select
yarn add #react-select/<github url>#head=<Name of branch>&workspace=react-select
I've tried it with ssh, with git+. with everything that the yarn website says and all i get is react-select installed but i don't see the code changes thats in my branch.
I've also tried to install the react-select package that the monorepo uses, but i get the following error
yarn add react-select#https://github.com/<USERNAME>/react-select/tree/master/packages/react-select
Failed with errors in 0s 290ms
(node:11491) UnhandledPromiseRejectionWarning: Error: react-
select#https://github.com/USERNAME/react-
select/tree/master/packages/react-select isn't supported by
any available resolver
i am using yarn 2.4.2
Has anyone dealt with this?
Any solution besides just copying the folder and installing it from a file path?
I had the same issue but upgrading to yarn version 2 worked. The following syntax for adding workspaces only starts working from yarn 2 on:
yarn add #react-select/monorepo#<GithubUsername>/react-select#head=<Name of branch>&workspace=react-select

Encounter errors when create react project

When I try to run npm create-react-app <name>, I encounter error reports. I've tried updating my node.js/npm and several other things and just don't work.
as you see in the error message, you have to install the last version of Visual Studio, take a look at node-gyp README, there is a guide to install and configure the dependencies.
suggest: use the npx to initialize a new react project with CRA, this way you will install the latest version each time.

How to install React on WebStorm

I'm having trouble installing React on an empty project in WebStorm. The instructions on the WebStorm help page tells me to get create-react-app.
Is there a way I can just get react? And if not, what is the difference between the two?
I'm trying to follow this specific tutorial series online about React for beginners. It's a 4 minute video so can anyone please explain to me what the youtuber did?
I would recommend using create-react-app because you will not need to install or configure tools like Webpack or Babel.
You need to install it from https://github.com/facebook/create-react-app if you have npm (node package manager) installed you can just type npm install -g create-react-app

Jest fails with error: Cannot find module 'react/lib/ReactComponentTreeHook'

I have installed Jest v17.0.3 in my react project.
When I run jest locally it works fine, but on the build server it fails with:
Error: Cannot find module 'react/lib/ReactComponentTreeHook' from 'ReactDebugTool.js'
Both machines are running node version 6.9.1 and npm version 4.0.2.
use same version of react and react-dom. My problem fixed after using this command
npm install --save react#15.4.0 react-dom#15.4.0
this problem specially occurs on react 15.4.0 above.
Can you check which version of React you are using? Is it the same on both servers? I would try removing node_modules and reinstalling the dependencies. The reason I am suggesting this is that in React v15.4.0 you cannot import private apis and it seems that ReactDebugTools.js is trying to import from react/lib/....
From the blogpost about React v15.4.0 (Link):
However, there is a possibility that you imported private APIs from react/lib/*, or that a package you rely on might use them. We would like to remind you that this was never supported, and that your apps should not rely on internal APIs. The React internals will keep changing as we work to make React better.
Hope this helps!
In the latest versions of react we often see this error as we have loaded 2 versions of react:
To make sure you have just 1 version, run the following in your terminal:
npm ls react-dom
npm ls react
Both the react and react-dom versions need to be same.
If any one of these returns more than 1 version then that's not supported. You have to then correct it in your corresponding package.json
I had the same issue and i removed the node_modules and ran npm install and it fixed the problem.

Resources