繁体   English   中英

-bash: nvm: 命令未找到

[英]-bash: nvm: command not found

当我使用命令 wget 或 curl (OS X El Capitan 10.11.4) 安装 nvm 时,控制台会打印

=> nvm is already installed in /Users/weichuang/.nvm, trying to update using git

=> 
=> Source string already in /Users/weichuang/.bashrc
npm ERR! error in /usr/local/lib/node_modules/love: ENOTDIR: not a directory, open '/usr/local/lib/node_modules/love/package.json'
npm ERR! missing: npmlog@, required by npm-registry-client@7.0.7
npm ERR! missing: prompt@^0.2.14, required by react-native-cli@0.1.4
=> You currently have modules installed globally with `npm`. These will no
=> longer be linked to the active version of Node when you install a new node
=> with `nvm`; and they may (depending on how you construct your `$PATH`)
=> override the binaries of modules installed with `nvm`:

/usr/local/lib
├── commander@2.9.0
├── cordova@5.3.3
├── download-cli@1.0.1
├── express@4.13.3
├── express-generator@4.13.1
├── forever@0.14.1
├── hexo@3.1.1
├── http-server@0.8.5
├── ionic@1.7.14
├── ios-deploy@1.8.2
├── ios-sim@5.0.3
├── JSONStream@1.0.6
├── koa@1.1.2
├──  error: ENOTDIR: not a directory, open '/usr/local/lib/node_modules/love/package.json
├── marked@0.3.5
├── n@2.0.2
├── node-gyp@3.2.0
├── nw@0.12.3
├── nw-gyp@0.12.4
├── react-native-cli@0.1.4
├── react-tools@0.13.3
├── remem@1.0.3 -> /Users/weichuang/Desktop/rem/remem
├── showdown@1.2.3
├── supervisor@0.6.0
└── typescript@1.6.2

=> If you wish to uninstall them at a later point (or re-install them under your
=> `nvm` Nodes), you can remove them from the system Node as follows:

     $ nvm use system
     $ npm uninstall -g a_module

=> Close and reopen your terminal to start using nvm

虽然我关闭并重新打开终端以开始使用 nvm,但问题仍然是-bash: nvm: command not found

输入终端

source ~/.nvm/nvm.sh
source ~/.profile
source ~/.bashrc

我的回答基于 Mac OS X,但我确信它适用于其他基于 Linux 的系统。

在 Mac OS X 上安装和使用 nvm

  • 这里安装自制软件。
  • 使用自制软件安装 nvm

    brew update brew install nvm

  • ~/.nvm位置创建.nvm目录。

    mkdir ~/.nvm

  • 现在,如果您没有为 OS X 终端设置.bash_profile文件,那么请在根级别创建一个.bash_profile

    nano ~/.bash_profile

  • 将以下代码粘贴到.bash_profile ,然后按CTRL + O并按 Enter 保存.bash_profile文件。 CTRL + X退出编辑器:

    export NVM_DIR=~/.nvm source $(brew --prefix nvm)/nvm.sh

  • 现在要么相当( CMD + Q )终端或运行下面的命令来加载.bash_profile设置:

    source ~/.bash_profile

  • 现在运行nvm ls命令以获取所有已安装 nodejs 版本的列表。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM