Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install a locally developed npm package globally

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?

like image 268
Kuba Orlik Avatar asked Feb 10 '15 20:02

Kuba Orlik


People also ask

How would you install a npm package globally?

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.

Does npm install locally or globally?

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>

What does it mean to install npm globally?

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.


1 Answers

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

like image 92
sathishkumar.T Avatar answered Oct 03 '22 09:10

sathishkumar.T