node_modules icon indicating copy to clipboard operation
node_modules copied to clipboard

"Developing in the monorepo" instructions incomplete

Open mikesamuel opened this issue 7 years ago • 0 comments

I ran into a problem with the previous startup instructions.

_scripts/build.sh and friends assume tools in ../node_modules/.bin relative to _scripts.

https://github.com/calebmer/node_modules/blob/770648585a7f96aa75604578146a08a8aec8bbf6/_scripts/build.sh#L7-L9

Normally npm install in a directory that contains a package.json will create a node_modules subdirectory, but not when the current directory is named node_modules.

Renaming the node_modules directory to something else, running npm install, and then changing the directory back does not work because require(...) will not look for a node_modules subdirectory inside a node_modules directory.

This happens because of how require(...) searches ancestor-ward:

NODE_MODULES_PATHS(START)

  1. let PARTS = path split(START)
  2. let I = count of PARTS - 1
  3. let DIRS = [GLOBAL_FOLDERS]
  4. while I >= 0, a. if PARTS[I] = "node_modules" CONTINUE

The changed setup instructions address the problem by cloning into a different directory name so that there is no node_modules path element on "$PWD".

mikesamuel avatar Jun 13 '18 16:06 mikesamuel