【问题标题】:npm module installed but not available?npm 模块已安装但不可用?
【发布时间】:2011-04-08 10:53:32
【问题描述】:

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

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 我可以看到

wrench@0.1.0

这里有什么我遗漏的吗?

谢谢,

埃利亚斯

【问题讨论】:

  • 你使用哪个版本的 npm 和 node.js?

标签: node.js npm


【解决方案1】:

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

我有:

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 npm@0.2.17
npm info using node@v0.4.1
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 wrench@0.1.0
npm info install wrench@0.1.0
npm info postinstall wrench@0.1.0
npm info preactivate wrench@0.1.0
npm info activate wrench@0.1.0
npm info postactivate wrench@0.1.0
npm info build Success: wrench@0.1.0
npm ok

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

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

【讨论】:

  • 您也可以尝试:npm list列出所有已安装的节点模块。
猜你喜欢
  • 2017-09-13
  • 2017-03-13
  • 1970-01-01
  • 2023-03-24
  • 2020-06-09
  • 2015-08-23
  • 2022-10-08
  • 2018-05-27
  • 1970-01-01
相关资源
最近更新 更多