模块没有全局安装“npm -g install ...”

时间:2022-11-14 22:57:51

On Ubuntu 12.04 x 64...

在Ubuntu 12.04 x 64上...

npm -g install hiredis redis

npm -g install hiredis redis

Installs fine and npm ls shows those modules, but only when I'm in node source directory

安装正常,npm ls显示这些模块,但仅限于我在节点源目录中

does not show when I'm in any other directory

我在任何其他目录时都没有显示

For kicks, tried running the command while in that other directory- still no dice :(

对于踢,尝试在其他目录中运行命令 - 仍然没有骰子:(

2 个解决方案

#1


1  

They are installing globally, but you cannot see them with npm ls, in other directories. Because npm ls only shows local modules. If you want to list global modules you have to type: npm ls -g.

它们是全局安装的,但在其他目录中你无法使用npm ls看到它们。因为npm ls只显示本地模块。如果要列出全局模块,则必须键入:npm ls -g。

#2


0  

Sometimes another version or just a wrong path is referenced in the npm config file instead of the installed version.

有时在npm配置文件中引用另一个版本或只是一个错误的路径而不是已安装的版本。

This may cause node/npm to misplace global modules.

这可能导致node / npm错放全局模块。

To check and fix:

检查和修复:

  1. In cmd line type: npm config list
    You should get a list of configuration values, one of them is prefix.
  2. 在cmd行类型中:npm config list你应该得到一个配置值列表,其中一个是前缀。

  3. Make sure the path in prefix is the same path (only without node.exe) as the actually installed node.exe path.
    (this path is listed further down as node bin location)
  4. 确保前缀中的路径与实际安装的node.exe路径的路径相同(仅限没有node.exe)。 (此路径作为节点bin位置进一步列出)

  5. If it's not, change it:

    如果不是,请更改它:

    • Either in the config file (in your user folder, named .npmrc)
    • 在配置文件中(在用户文件夹中,名为.npmrc)

    • Or, via cmd line: npm config set prefix "C:\Program Files\nodejs" (change path for ubuntu of course)
    • 或者,通过cmd行:npm config set前缀“C:\ Program Files \ nodejs”(当然是更改ubuntu的路径)

  6. Reinstall the module/package you tried to install, don't forget -g for global.

    重新安装您尝试安装的模块/包,不要忘记-g for global。

#1


1  

They are installing globally, but you cannot see them with npm ls, in other directories. Because npm ls only shows local modules. If you want to list global modules you have to type: npm ls -g.

它们是全局安装的,但在其他目录中你无法使用npm ls看到它们。因为npm ls只显示本地模块。如果要列出全局模块,则必须键入:npm ls -g。

#2


0  

Sometimes another version or just a wrong path is referenced in the npm config file instead of the installed version.

有时在npm配置文件中引用另一个版本或只是一个错误的路径而不是已安装的版本。

This may cause node/npm to misplace global modules.

这可能导致node / npm错放全局模块。

To check and fix:

检查和修复:

  1. In cmd line type: npm config list
    You should get a list of configuration values, one of them is prefix.
  2. 在cmd行类型中:npm config list你应该得到一个配置值列表,其中一个是前缀。

  3. Make sure the path in prefix is the same path (only without node.exe) as the actually installed node.exe path.
    (this path is listed further down as node bin location)
  4. 确保前缀中的路径与实际安装的node.exe路径的路径相同(仅限没有node.exe)。 (此路径作为节点bin位置进一步列出)

  5. If it's not, change it:

    如果不是,请更改它:

    • Either in the config file (in your user folder, named .npmrc)
    • 在配置文件中(在用户文件夹中,名为.npmrc)

    • Or, via cmd line: npm config set prefix "C:\Program Files\nodejs" (change path for ubuntu of course)
    • 或者,通过cmd行:npm config set前缀“C:\ Program Files \ nodejs”(当然是更改ubuntu的路径)

  6. Reinstall the module/package you tried to install, don't forget -g for global.

    重新安装您尝试安装的模块/包,不要忘记-g for global。