Answer the question
In order to leave comments, you need to log in
Node js how to add custom module without full path?
I can't find it and can't remember, please help me.
Here is my module. I need access to it from all other places without the full path.
Where and how to shove it (what should be written where) so that it can be called, for example var express = require("express");
Answer the question
In order to leave comments, you need to log in
In the example, express is used as a dependency that is installed from node_modules, and there, in turn, is installed from NPM, which means that the package must be published on npmjs or in other sources (repository, for example)
You can run npm list -g
to see where the global libraries are installed.
And push your module there, node will search there by default.
On Unix systems they are usually placed in /usr/local/lib/node
Windows 7, 8 and 10 - %USERPROFILE%\AppData\Roaming\npm\node_modules
- use https://docs.npmjs.com/files/package.json#local-paths
- use lerna https://github.com/lerna/lerna
- put a symlink to the required module in ./node_modules manually
- use software for folder sync (eg lsyncd)
- use NODE_PATH https://nodejs.org/api/modules.html#modules_addend...
- override node dependency resolution mechanism https://tech.wayfair.com/2018/06/custom-module -loa...
- redefining the dependency resolution mechanism by webpack https://webpack.js.org/concepts/module-resolution/
you can also read here https://gist.github.com/branneman/8048520
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question