使用NVM时找不到NPM和NODE命令 [英] NPM and NODE command not found when using NVM

查看:914
本文介绍了使用NVM时找不到NPM和NODE命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看到其他问题,但我认为这不是我的情况.

Seen other questions, but I think they are not my case.

我认为问题已经解决了,但我不知道如何解决:

I think the problem is over here, but I don't know how to solve it:

我确实安装了最新的Node版本(我遵循了官方的github页面说明)

I do have latest Node version installed (I followed the official github page instructions)

> nvm install v7.3.0
v7.3.0 is already installed.
Now using node v7.3.0

我检查安装的节点和npm版本

I check node and npm versions installed

> which node
~/.nvm/versions/node/v7.3.0/bin/node

> which npm
~/.nvm/versions/node/v7.3.0/bin/npm

我检查PATH是否正确

I check the PATH is right and it actually is

> echo $PATH
~/.nvm/versions/node/v7.3.0/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

但是它仍然失败,当我浏览nvm文件夹时...我找到了,我不知道如何更改或解决该问题:

But it still fails and when I browse through nvm folders... I find this, which I don't know how to change or solve:

> ls -a .nvm/versions/node
.
..
.DS_Store
v6.4.0 // WTF???

我保证我什么也不做,我的意思是……这是一个全新安装,.nvm文件夹在安装nvm之前不存在.

And I promise I didn't do anything, I mean... this is a clean install, .nvm folder didn't exist before installing nvm.

推荐答案

如果要在所需的位置安装所需的版本,则可以在GitHub上按照我的教程进行操作:

If you want to install the version you want in the place you want then you can follow my tutorial here on GitHub:

它与版本6.7.0有关,但是您可以将其更改为任何其他版本.它向您展示了如何从源代码或二进制软件包进行安装,并且在该教程之后,您将始终知道哪个版本在哪里,因为您可以完全控制安装过程,而不必依赖自动为您进行安装的工具.

It's about version 6.7.0 but you can change it to any other version. It show you how to install either from source or from binary packages and following that tutorial you will always know which version is where, because you have full control over the installation instead of relying on tools that do that automatically for you.

例如,如果要在/usr/local中具有Node 7.3.0,则它只是:

If you want to have Node 7.3.0 in /usr/local for example the it is just:

wget https://nodejs.org/dist/v7.3.0/node-v7.3.0.tar.gz
tar xzvf node-v7.3.0.tar.gz
cd node-v7.3.0
./configure --prefix=/usr/local
make && make test && echo OK || echo ERROR
sudo make install

这篇关于使用NVM时找不到NPM和NODE命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆