0

I am trying to integrate 2 react apps I have been working on into 1 new react application (all created using npx create-react-app nameofapp) but I can not get the libraries I have used in the previous app to load/work in the new application even though I have copied the depencencies from the previous application and pasted in the new package.json file and run npm i and can see the folders for the libraries in node_modules folder of new application.

I am only importing fs in the js file from previous application at the moment and still get an error when running npm start which is module not found and it seems to be looking in the src file probably because the js file is in the src folder which is using import fs from "fs" to work with the fs package.

One other thing I can see different is that I had to run node app on previous application in src folder to start it where npm start runs this application.

I'd really appreciate help with this as I am still new to node and have been stuck all day on just integrating 2 applications into one.

  • "_I am only importing fs in the js file from previous application _" - `fs` is a Node module that does not work in the browser. ("_which is using import fs from `fs`_"). There is more to this story to understand. For instance, the difference between staring a Node server (`node app` vs. `npm start`). More details please. – Randy Casburn Jan 14 '23 at 20:15
  • fs is a node module – Roohullah Kazmi Jan 14 '23 at 20:20
  • both previous and new application have the same folder directory - node_modules, public and src. Could you tell me where I could see how/where one is defined as a server app (or is just a case of using node app instead of npm start) in the file/folders to help understand how these applications are different please. – user1092538 Jan 14 '23 at 21:05
  • Your comments have helped me to start to understand Randy, thank you. So I have created and been running 2 applications - one was a front end application and one was a back end which is why they can't be so easily integrated. Could you tell me please in this case where i need to use libraries which only work on the server (i.e fs) is the right approach to have 2 applications and is there a way to communicate with them if it is please? – user1092538 Jan 14 '23 at 21:21

0 Answers0