为什么通过npm安装的这个包找不到

huangapple go评论62阅读模式
英文:

Why this package installed by npm is not found

问题

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

我正在使用更新的Debian Stable Linux,并且一切工作正常。

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

我已经使用以下npm命令全局安装了compute-pcorr包:

$ sudo npm install compute-pcorr -g

It is listed with following npm command:

它在以下npm命令中列出:

$ 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?

问题出在哪里,如何解决?

英文:

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?

答案1

得分: 1

这个问题发生在库未在本地安装时。尝试使用命令 npm install compute-pcorr 在您的目录中进行本地安装。不需要通过 -g 进行全局安装。

英文:

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

huangapple
  • 本文由 发表于 2023年5月17日 14:04:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76268981.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定