Monday, 5 June 2017

Restrict Node.js require search paths

My repository has two separate node projects inside of it, and the structure is like this

/index.js /node_modules -/otherApp --/index.js --/node_modules The issues is that require in the otherApp/index.js will search the node_modules in the base directory, meaning if we accidentally forget something in otherApp/package.json and it is in /package.json we might not notice, because require will still find the module one level up.

Is there any way to restrict the search paths of require to not leave otherApp/*?



via PunDefeated

No comments:

Post a Comment