I'm developing a node package that needs to be run from shell. I know I have to install the package globally, but running
$> npm install -g ./my_module
Does not give me the desired result, that is running
$> my_module
Results in
my_module: : command not found
Instead of running the entry point (index.js
) of my node package.
I feel like I'm missing something obvious in here, what am I doing wrong?
To install a module from npm globally, you'll simply need to use the --global flag when running the install command to have the module install globally, rather than locally (to the current directory). Note: One caveat with global modules is that, by default, npm will install them to a system directory, not a local one.
local packages are installed in the directory where you run npm install <package-name> , and they are put in the node_modules folder under this directory. global packages are all put in a single place in your system (exactly where depends on your setup), regardless of where you run npm install -g <package-name>
npm install (with --global) This means the package is installed in two places. The first is at the root directory where package. json is defined. The second is the global node_modules folder on the user system.
Please try to pack the module and install.
npm pack
and then install it globally
npm i -g my_module-0.0.1.tgz
Let me know is this worked or not
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With