Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why this package installed by npm is not found

I am working on Debian Stable Linux which is updated and working very well.

I have installed a compute-pcorr package globally with following npm command:

$ sudo npm install compute-pcorr -g

It is listed with following npm command:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

$  npm list -g --depth=0 
/usr/local/lib
├── compute-pcorr@1.0.0
└── ml-stat@1.3.3

I am now trying following code demo code from its homepage:

var pcorr = require( 'compute-pcorr@1.0.0' ); 

var x = [ 1, 2, 3, 4, 5 ]; 
var y = [ 5, 4, 3, 2, 1 ];

var mat = pcorr( x, y );
Console.log("Correlation Matrix: "+ mat)

However, when I run above code, I get error:

$ node compute_pcorr_usage.js 

internal/modules/cjs/loader.js:818
  throw err;
  ^

Error: Cannot find module 'compute-pcorr@1.0.0'

Following in code is also not working:

var pcorr = require( 'compute-pcorr' ); 

I also tried to reinstall package with following command, but error persists:

sudo npm install compute-pcorr -g --save

Where is the problem and how can it be solved?

>Solution :

This issue happens when the library is not installed locally.
Try installing locally in your directory with the command npm install compute-pcorr
There’s no need of installing globally via -g

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading