'How to use one project as a local dependency in another project React js

Hi i have created two projects the first . Project A is the main project and i have created one more project , project B.Now i want to use project B as a local dependency in my project A. As I tried this way in my package.json file of the project A.but I am not sure how to do it in a right way.

preinstall:"cd ./projectB && npm i &&npm run build&& npm run copy"


Solution 1:[1]

Just copy the package.json -> dependencies of projectB under package.json -> dependencies of projectA, and then run npm install on projectA, you won't need node_modules folder in projectB anymore

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Antonio Della Fortuna