Uncertain about your intentions, but utilizing global dependencies within your code is not the recommended approach.
If you need some guidance, you can input npm help folders
for a brief explanation:
- When doing a local install (default), the content is saved in ./node_modules within the current package root.
- For a global install (using -g), the content is stored in /usr/local or the specified node installation location.
- Opt for a local install if you will be using
require()
.
- Choose a global install if the intention is to run it through the command line.
- If both are needed, install in both locations or employ npm link.
In this scenario, the link
option mentioned earlier is the solution: https://docs.npmjs.com/cli/link.
Execute npm link jshint
in the base directory. This action will establish a link from node_modules/jshint to the global installation. A symbolic link to the binary file will be created, but remember, this cannot be used within require()
in your code. Global packages are designed for command line execution as they consist of binary files.