Wednesday, 17 May 2017

Reference NodeJS libs from locations other than "node_modules" without using relative path

Assuming that I have 2 folders for NodeJS libs ie "node_modules" and "somename_modules". The latter is the folder that stores internally developed libraries which are proprietary.

I know that when we reference using "import" or "require", the default location is always point to the path where "node_modules" folder reside in the project.

My question is, how do we add another default location to where "somename_modules" is located so that when we reference using "import" or "require" in ES6 source code it will always check for libs from both "node_modules" and "somename_modules"?

Example:

import somefunc from 'somelib' //it will search in './node_modules/somelib' and './somename_modules/somelib'



via oatcrunch

No comments:

Post a Comment