-1

When we clone any repository from bitbucket or any other platform, we did not get node modules with it. So when we run gatsby develop it says 'there was a problem loading the local development command. Gatsby may not be installed in your site's node_modules'. Perhaps run npm install'. But when I run npm install it takes a lot of time and then the error comes 'SOCKET_ERR'. So is it due to node_modules not cloning or do I need to install all plugins from scratch?

1 Answers1

1

node_modules must not be uploaded to the repository, never. So, answering your question, yes, you will always need to install the dependencies each time you clone a repository. Why?

There are many reasons but essentially:

  • node_modules are heavy, so it's not worth uploading that bunch of dependencies into a repository. You are saving hundreds of MB.
  • node_modules are strictly related to the running environment (OS, dependency versions, Node, version, etc) so each time you run npm install you are installing the right version of each module. Doing it in the opposite way will cause issues across the project
  • It will save you from multiple git conflicts across merges. A pull request or merge if changing the dependencies, is going to have much more files involved in the process. Tools become slower or even decide to not show the full diff (GitHub, for example)
  • Not committing (and pushing) node_modules implies you need to list all your modules in the package.json (and package-lock.json) as a mandatory step. This is great because you might not have the diligence to do so, and some of the npm operations might break if you don’t.

Ideally, the full installation process should only happen the first time (or when having to delete the node_modules due to some configuration issue or conflict).

Regarding your SOCKET_ERR, it may have multiple origins but sometimes is caused by the node-gyp dependency (related to Python version), try reinstalling or rebuilding again.

Ferran Buireu
  • 28,630
  • 6
  • 39
  • 67