Why can't I read source code of React in node_modules - javascript

I'd like to explore the source code of React, but in my node_modules with create-react-app, I can't find it.
For example I wanna read this original code (https://github.com/facebook/react/blob/0f4a83596646c610c06b751fc8ac0fc51f90d796/packages/react-reconciler/src/ReactFiberHooks.js), but it seems like it doesn't exist in node_modules. I searched it inside the folder but failed. I wanna know why.
React folder in my node_modules:

Related

How to compile a folder with multiple files JS format, node_modules, package.json to an executable

Good evening, I would like to know if there's a way to compile what I asked in the title to an executable. I've tried in the past using the node library /nexe with success, but the exe would work only inside the root folder with all its components. If you try to run it outside the folder it won't work. I've tried pkg but without success as it would crash when opening. I've tried Dino but same result. If there's something I'm missing let me know.
The root folder structure is pretty simple and contains the following.
node_modules
package.json
package-lock.json
folder with JS files that are connected to main.js
main.js

Absolute path work on a react project installation, but fails on another. Why?

I create a project with create-react-app and do many staff on my office. On my imports im using no relative path on folders:
project-folder
src
components
reducer
On my reducer folder i made a import like this:
import componentX from "components/mycommponent/componentX"
and on my office, works without problem.
On my home, i just download the project do 'npm install' a try to run the project
and the same file don't find the componentX and i donĀ“t know why. I have several imports on that project and, if possible, don't want to change all my imports.
Can you guy know why this happen?
At the root of the project create a .env file... To that file add NODE_PATH=src/
Now you do not need to use relative imports... (Note: since I don't know the exact directory structure of your project use some common sense and adapt the solution to your specific situation)
My guess would be that said .env file is probably in the .gitignore and you didn't get it when cloning the repo...
In case error or missing component is of some node package the you most probably for got to add --save with package install and you package json is not updated.
then you can check by ls node_modules and check for missing dep in package json.
In other case like error is from your code you have to share error and some code.
In case of any query ping me or update you question.
I will update my ans.

How to correctly build a package so that suggestions/autocomplete work in intellij when this private styleguidist packages is used in another project

I made my own style guide using react-styleguidist and typescript. Now after building the node package (private) and importing (npm install) it into my other project (where I want to use my style guide components) I am not able to get intellij suggestions to work.
My folder structure is (some files are omitted):
My-library/
package.json
README.md
lib/
components/
Alert/
Alert.d.ts
Alert.d.ts
index.d.ts
index.js
Other_Components/
css/
fonts/
icons/
index.d.ts
index.js
styled-components.d.ts
styled-components.js
I did already check if my node_modules folder of my project was marked as library root (which it is) and I also checked if my package was showing up as not excluded.
My own style guide library works fine, I can use my components and type checking works as well.
I have been looking online for a good guide of how to build/package your project so that these IDE(suggestions/autocomplete) functions work correctly.
When I used the ant design(https://ant.design/) library in intellij and typed <Bu intellij would suggest me <Button>
Same goes for when using Material-ui and the extra #types/material-ui npm package
This is what I would like to achieve with my own npm package as well.
I have no clue if the problem is in my import/exports (default)/index files or in one of my config files (package.json, .babelrc or tsconfig.json, webpack.config.js)
In Visual code this works, so it has to be a bug in Intellij.
It has to do with exporting my component with styled-components like this in my Button.tsx file:
export default styled(Button)`
This is the bug report I found on Jetbrains youtrack:
https://youtrack.jetbrains.com/issue/WEB-33709

accidentally created extra .git folder and now can't access js folder in github

I see the js folder in GitHub but unlike my css folder the js folder icon has 2 folders instead of one like the others. It should only have the main.js file in it, not another folder.
Also, I can't access the folder because folder title js is not a link and main.js is not even listed in the file finder.
Looking through terminal I see that there is a .git folder inside the js folder. The project folder has a .git folder in it as well.
I'm following a tutorial and when the tutorial instructed to stage and push the code to my GitHub repo, I accidentally did that from inside the js folder at first, then I did it again from the main project folder. I'm pretty sure this is where something went wrong.
How do I fix this? I'm assuming remove the .git folder inside the js folder but not sure how to do that and also scared that everything might get deleted.
Thanks in advance! I'm a beginner, please be patient with me :)
Removing the .git folder will work. The command is simple rm -rf .git. But if you don't have idea how to use it, better to follow below method. Otherwise there is a chance to remove the other folder unkwnowingly
Use pwd command to get the present working directory. Let's say your project folder is : /home/tina/workspace/myproject.
If so, use this command -
rm -fr /home/tina/workspace/myproject/jsfolderpath/.git . So that you can make sure the directory you are deleting is correct one.
Note:
rm => command to remove
f => run the command in force
r => run the command recursively

Migration to React 16.0.0 Error: Cannot find module "react/lib/ReactComponentTreeHook"

Trying to migrate from react 15.6.1 to 16.0.0. I have updated my package.json, to "react": "16.0.0","react-dom": "16.0.0", (only things I changed so far), and from what I've understood from the changelogs, things should have gone smoothly. But they don't! From what I understand, they removed the /lib part in the v16.0.0, hence why the module cannot be found?
Am I missing something obvious? Would appreciate any help! :)
You probably have two copies of React loaded.
Try this in your terminal:
npm ls react
And also:
npm ls react-dom
If either of these commands shows more than one result, then you have two copies of React, and that is not supported.
Delete all copies except the ones in the root node_modules, and file an issue with projects that specify React as a dependency. It must be a peerDependency so that a situation like this doesn't occur.

Categories

Resources