npm 模块已安装但不可用?

发布于 2024-10-31 04:42:27 字数 951 浏览 1 评论 0原文

我在一个应用程序中实现了一个 npm 模块(称为 wrench),我总是在本地测试该模块。这总是没有问题的。然后我尝试在我的服务器上安装扳手。

npm install wrench 确实按预期工作,但是一旦涉及 require("wrench"),我会收到以下错误:

> require("wrench")
Error: Cannot find module 'wrench'
    at Function._resolveFilename (module.js:320:11)
    at Function._load (module.js:266:25)
    at require (module.js:348:19)
    at [object Context]:1:1
    at Interface.<anonymous> (repl.js:171:22)
    at Interface.emit (events.js:64:17)
    at Interface._onLine (readline.js:153:10)
    at Interface._line (readline.js:408:8)
    at Interface._ttyWrite (readline.js:585:14)
    at ReadStream.<anonymous> (readline.js:73:12)

如果我运行 npm ls< /code> 我可以看到

[email protected]

我在这里缺少什么吗?

谢谢,

埃利亚斯

I implemented a npm module (called wrench) in an application which I always tested locally. That worked always without problems. Then I was trying to install wrench on my server.

npm install wrench did work as expected but as soon as it comes to require("wrench"), I get the following error:

> require("wrench")
Error: Cannot find module 'wrench'
    at Function._resolveFilename (module.js:320:11)
    at Function._load (module.js:266:25)
    at require (module.js:348:19)
    at [object Context]:1:1
    at Interface.<anonymous> (repl.js:171:22)
    at Interface.emit (events.js:64:17)
    at Interface._onLine (readline.js:153:10)
    at Interface._line (readline.js:408:8)
    at Interface._ttyWrite (readline.js:585:14)
    at ReadStream.<anonymous> (readline.js:73:12)

If I run npm ls I can see

[email protected]

Is there something I am missing here?

Thanks,

Elias

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听,心雨的声音 2024-11-07 04:42:27

我相信 npm ls 显示了 npm 上所有可用的软件包。要查看已安装的软件包,我认为您应该发出npm lsinstalled

我有:

alfred@alfred-laptop:~$ node -v
v0.4.1

alfred@alfred-laptop:~$ npm --version
0.2.17

我的问题:

alfred@alfred-laptop:~$ npm install wrench
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info fetch http://registry.npmjs.org/wrench/-/wrench-0.1.0.tgz
npm info calculating sha1 /home/alfred/local/lib/node/.npm/nvm/0.0.6/package/v0.4.1/lib/node/.npm/.cache/wrench/0.1.0/package.tgz
npm info shasum 07440ad670068e0e81c8126c4641d1ca73b83557
npm info preinstall [email protected]
npm info install [email protected]
npm info postinstall [email protected]
npm info preactivate [email protected]
npm info activate [email protected]
npm info postactivate [email protected]
npm info build Success: [email protected]
npm ok

alfred@alfred-laptop:~$ node
> require('wrench')
{ rmdirSyncRecursive: [Function],
  copyDirSyncRecursive: [Function],
  chmodSyncRecursive: [Function] }
>

我的建议是使用最新最好的 npm 和 node.js,然后再试一次。

I believe npm ls shows all the the packages available on npm. To see the installed packages I think you should issue npm ls installed.

I have:

alfred@alfred-laptop:~$ node -v
v0.4.1

alfred@alfred-laptop:~$ npm --version
0.2.17

I issue:

alfred@alfred-laptop:~$ npm install wrench
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info fetch http://registry.npmjs.org/wrench/-/wrench-0.1.0.tgz
npm info calculating sha1 /home/alfred/local/lib/node/.npm/nvm/0.0.6/package/v0.4.1/lib/node/.npm/.cache/wrench/0.1.0/package.tgz
npm info shasum 07440ad670068e0e81c8126c4641d1ca73b83557
npm info preinstall [email protected]
npm info install [email protected]
npm info postinstall [email protected]
npm info preactivate [email protected]
npm info activate [email protected]
npm info postactivate [email protected]
npm info build Success: [email protected]
npm ok

alfred@alfred-laptop:~$ node
> require('wrench')
{ rmdirSyncRecursive: [Function],
  copyDirSyncRecursive: [Function],
  chmodSyncRecursive: [Function] }
>

My advice is to use the latest and greatest npm and node.js and try again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文