Why this package installed by npm is not found

Advertisements

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:

$  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

Leave a ReplyCancel reply