Manfred Tijerino
Manfred Tijerino

Reputation: 377

Does React.js require to have a node_modules folder to run?

I am asking this question, because I installed react for a project, I made some changes as usual, I received the error message below. I searched to see where that error was coming from, and one of the solution was to delete the node_modules folder from react, and then run npm.

I did that, and now it is working. But, I am checking the frontend folder and the node_module folder is not there. There is only one node_module folder, but it is in the backend folder.

enter image description here

Upvotes: 6

Views: 24984

Answers (4)

theshubhagrwl
theshubhagrwl

Reputation: 1036

I think this is happening because you are missing the node_modules folder in your react app.
This is a simple fix
Just go in your react app and run

npm install

or

yarn install

this will create the node_modules folder for you.

Upvotes: 2

Gary Vernon Grubb
Gary Vernon Grubb

Reputation: 11245

React can be run without node_modules, npm and without installing additional dependencies. You will have to import the production build from a CDN. Check out this link for more information and a working example.

Although I usually recommend sticking to doing it using create-react-app. They have really put a lot of thought into it.

Upvotes: 2

Raja
Raja

Reputation: 88

Regarding Node_Modules folder: For single project it require 1 node_modules folder. In simple word node_modules folder is the repository of modules/library which you are using inside your project. What ever you are importing in your project that module or library should present inside the mode_module folder.When you do npm install that time that module or the library install inside the node_module folder and one entry added in package.json file. In your case frontend and backend are different project than obviously there will be 2 different node_modules folder for each of them.

But you can use single node_modules folder in you frontend and backend both project also. Please look into this answer Let me know if you have any doubt.

So,your answer is Yes React.js requires a node_modules folder to run.

Upvotes: 3

Abdurauf Sherkulov
Abdurauf Sherkulov

Reputation: 61

Of course it does require. If you open your package.json, you will find minimal dependencies that are required to run simple react.js app if you are using CRA. Regarding you problem, if you deleted node_modules folder (delete package-lock.json as well), you will have to rerun npm install command to install all dependencies.

Upvotes: 1

Related Questions