node.js - Setting NODE_PATH from within NodeJS application -
We have a node project, for which our own submodules are not required from any relative path, but instead < Code> NODE_PATH Environment variables can be set to I want to handle this standard case within the program source code But it seems that it is impossible by now. I have found many solutions that do not work as expected at all. Another Stackworflow article was suggested but it refers to the developer to use an error message in the new node versions and Instead, I tried to do the following as the first line of my program. This is not the cause of an error message, but it does not work either. I think this variable is read on starting the app and does not read the lateron when the content is necessary. You can find all the information from the source: So now, if you have What is the node version and what system do you have? lib to find all the codes
Module paths.push (". / Lib");
NODE_PATH .
process.env ['NODE_PATH'] = "./ lib";
. .. NODE_PATH error is thrown only when reaching through
need.paths .
Search for the _nodeModulePaths function: The module instance has the generic array object
path , with all the lookup paths in it.
module.paths.unshift ('./foo-baz'); Var x = Required ('some-lib-name'); Console.log (x);
. If there is a module under / Foo-baz / some-lib-name / , then it will be picked properly.
Comments
Post a Comment