It is not uncommon to want to be able to have non-relative imports, for example, for configuration, etc...
In the world of running a node executable on your own (development env, any cloud provider... things like that) you can simply set an env var and have it respected by the node runtime.
Imagine a project structure like so: dist |--foo |--bar |--baz app.js |--config
in app.js with NODE_PATH=dist, I can simply require('config') and have what I need.
Within Azure App Services, it appears to ignore NODE_PATH from Application Settings. Is something missing or is this not possible?
In Azure App Services, you can set the
NODE_PATH
environment variable in the Azure portal with the following steps.1, Create the
D:\home\site\my_node_modules\config
directory and put the index.js file in where. In this case, I just export the "name" variable.2, Navigate to your App Service in the Azure portal, click on Application settings in the SETTING menu and then set the
NODE_PATH
variable as below:3, In the
app.js
file, you can simplyrequire('config')
like this:4, At last, it works fine.