UbuntuにnodeJSを以下のコードでインストールしました。
sudo apt-get install nodejs
私はubuntuの新しいユーザーなので、このコードも実行しました。
sudo apt-get install npm
と入力すると
nodejs --version
と表示されます。
v0.6.19
確認したところ、nodeJSの最新バージョンは0.10.26
でした。
nodeJSのバージョンを0.10.26
に更新するにはどうしたらよいですか?
で試してみました。
sudo apt-get install <packagename>
sudo apt-get install --only-upgrade <packagename>
が、うまくいきません。
nodeのアップグレードにはnpmのnモジュールを使用します。
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
最新版(現在の安定版ではない)にアップグレードする場合は
sudo n latest
sudo apt-get install --reinstall nodejs-legacy # fix /usr/bin/node
sudo n rm 6.0.0 # replace number with version of Node that was installed
sudo npm uninstall -g n
David Walshのブログで発見 http://davidwalsh.name/upgrade-nodejs
その後、完全なインストール手順がhereによってNodesourceによってアップロードされました。 参照用に以下にコピーします。 手順は、最新バージョンに更新する場合と同じです。
カールが心配な場合-> sudo、彼らは手作業でセットアップを行う方法についての上のURLに指示があります。
Node.js v13.x :
注:Ubuntu PreciseまたはDebian Wheezyを使用している場合は、[古いディストリビューションでNode.js> = 6.xを実行]について読むことをお勧めします(https://github.com/nodesource/distributions/blob / master / OLDER_DISTROS.md)。
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_13.x | bash -
apt-get install -y nodejs
Node.js v12.x :
注:Ubuntu PreciseまたはDebian Wheezyを使用している場合は、[古いディストリビューションでNode.js> = 6.xを実行]について読むことをお勧めします(https://github.com/nodesource/distributions/blob / master / OLDER_DISTROS.md)。
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_12.x | bash -
apt-get install -y nodejs
Node.js v11.x :
注:Ubuntu PreciseまたはDebian Wheezyを使用している場合は、[古いディストリビューションでNode.js> = 6.xを実行]について読むことをお勧めします(https://github.com/nodesource/distributions/blob / master / OLDER_DISTROS.md)。
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_11.x | bash -
apt-get install -y nodejs
Node.js v10.x :
注:Ubuntu PreciseまたはDebian Wheezyを使用している場合は、[古いディストリビューションでNode.js> = 6.xを実行]について読むことをお勧めします(https://github.com/nodesource/distributions/blob / master / OLDER_DISTROS.md)。
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt-get install -y nodejs
Node.js v9.x :
注:Ubuntu PreciseまたはDebian Wheezyを使用している場合は、[古いディストリビューションでNode.js> = 6.xを実行]について読むことをお勧めします(https://github.com/nodesource/distributions/blob / master / OLDER_DISTROS.md)。
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_9.x | bash -
apt-get install -y nodejs
Node.js v8.x :
注:Ubuntu PreciseまたはDebian Wheezyを使用している場合は、[古いディストリビューションでNode.js> = 6.xを実行]について読むことをお勧めします(https://github.com/nodesource/distributions/blob / master / OLDER_DISTROS.md)。
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get install -y nodejs
Node.js v7.x :
注:Debian WheezyおよびUbuntu Preciseパッケージは NOT このリリースで利用できます。 古いディストリビューションでNode.jsを実行している> = 4.xを実行しているを参照してください。
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_7.x | bash -
apt-get install -y nodejs
Node.js v6.x :
注:Ubuntu PreciseまたはDebian Wheezyを使用している場合は、[古いディストリビューションでNode.js> = 4.xを実行]について読むことをお勧めします(https://github.com/nodesource/distributions/blob / master / OLDER_DISTROS.md)。。
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_6.x | bash -
apt-get install -y nodejs
Node.js v5.x :
注:Ubuntu PreciseまたはDebian Wheezyを使用している場合は、[古いディストリビューションでNode.js> = 4.xを実行]について読むことをお勧めします(https://github.com/nodesource/distributions/blob / master / OLDER_DISTROS.md)。。
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_5.x | bash -
apt-get install -y nodejs
Node.js v4.x :
注:Ubuntu PreciseまたはDebian Wheezyを使用している場合は、[古いディストリビューションでNode.js> = 4.xを実行]について読むことをお勧めします(https://github.com/nodesource/distributions/blob / master / OLDER_DISTROS.md)。。
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_4.x | bash -
apt-get install -y nodejs
Node.js v0.12 :
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_0.12 | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_0.12 | bash -
apt-get install -y nodejs
Node.js v0.10 :
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_0.10 | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_0.10 | bash -
apt-get install -y nodejs
io.js v3.x :
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_3.x | sudo -E bash -
sudo apt-get install -y iojs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_iojs_3.x | bash -
apt-get install -y iojs
io.js v2.x :
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_2.x | sudo -E bash -
sudo apt-get install -y iojs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_iojs_2.x | bash -
apt-get install -y iojs
io.js v1.x :
_注:このio.jsのブランチは積極的に維持されておらず、生産での使用は推奨されていません。
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_1.x | sudo -E bash -
sudo apt-get install -y iojs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_iojs_1.x | bash -
apt-get install -y iojs
このPPAは古く、もうメンテナンスされていませんので、この回答ではなく、他の回答を検討してください。
PPAから最新版をインストールすることができます。
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
私はNodeのバージョンを処理するためにNVMを使用しています。セットアップが非常に簡単で、使い勝手がよいです。
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
NVMをグローバルにインストールするには、上記のコマンドの代わりに以下のcurlコマンドを使用します(おそらく、2番目のコマンドは使用せず、3番目のコマンドを使用します)。
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | NVM_DIR=/usr/local/nvm bash
その後、 nvm install stable
(または stable
の代わりにバージョン番号を入れてください) を使って、Node の最新/特定のバージョンを取得します。その Node のバージョンを使用するには、 nvm use stable
(または特定のバージョン番号を入れてください) を使用します。インストールされている Node のバージョンを見るには nvm ls
を、特定のバージョンの Node を削除するには nvm uninstall stable
(または特定のバージョン番号) を使ってください。
また、代わりにnvmを使用することをお勧めします。また、端末での競合を回避するために、すでにインストールされているバージョンを削除することをお勧めします。
sudo apt purge nodejs npm
次にnvmをインストールして使用します。
[ビデオの説明](
===。curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
nvmをダウンロードしてインストールします。
nvm install node
ノードの最新バージョンをダウンロードしてインストールする必要があります。
後でノードを更新するには、実行してください。
nvm install node
nvm alias default node
ubuntu 14.04で同じリストコマンドを試しましたが、それでもエラーが発生していました。
私が実行したコマンドは次のとおりです。
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
そして私が得ていたエラー:
Invalid version 0.12.2
Line 299: curl not found in /bin/n
私が理解したのは、カールユーティリティが私のOSにインストールされていないことです。
コマンドを実行しました。
apt-get install curl
(「su」でない場合は、接頭辞として「sudo」を使用してください)。
次に、回答で提案された手順を繰り返すと、機能します;)。
--lts
。NVMは次の場所で言及されました:https://askubuntu.com/a/441527/52975ですが、正気な --lts
バージョンを含む、より完全な使用例の次に示します。
NVMは、最新の安定ノードとnpmの両方をインストールします。
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | sh
source ~/.nvm/nvm.sh
nvm install --lts
nvm use --lts
npm --version
次に、ダミーパッケージでテストします。
npm install --global vaca
vaca
ソーシングはすべての新しいシェルに対して実行する必要があるため、インストールスクリプトハックは、 。barshrc
の最後に自動ソーシングを追加します。 それは機能しますが、自動追加されたものを削除して、自分のものを追加することを好みます。
f="$HOME/.nvm/nvm.sh"
if [ -r "$f" ]; then
. "$f" &>'/dev/null'
nvm use --lts &>'/dev/null'
fi
利点:
-複数のバージョンのノードを使用でき、sudoを使用できません。
-Ruby RVMおよびPython Virtualenvに類似しており、RubyおよびPythonコミュニティで広く知られているベストプラクティスです。
-可能な場合は事前にコンパイルされたバイナリをダウンロードし、ダウンロードしない場合はソースをダウンロードしてコンパイルします。
ノードバージョンは次のように簡単に切り替えることができます。
nvm install 0.9.0
nvm install 0.9.9
nvm use 0.9.0
node --version
#v0.9.0
nvm use 0.9.9
node --version
#v0.9.9
次に、gitで追跡された .nvmrc
ファイルを使用して、特定のプロジェクトに必要なノードバージョンを示すことができます。https://stackoverflow.com/questions/24869959/how-do-i-specify-a-local-version -of-node-for-a-project / 54503474
Ubuntu 17.10でテスト済み。
これは最新のノードv0.12をインストールします。*ノードソースから。
sudo apt-get install -y curl
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
sudo apt-get install -y nodejs
ノードv4.xの場合。
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
まず、すべてのnodejsインストールを削除することをお勧めします。 次に、目的のnodejsバージョンとそのインストール親ディレクトリで編集したら、以下のスクリプトを実行します。
利用可能なすべてのnodejsバージョンを参照してください。
以下のスクリプトでは、LinuxまたはOSXにこれらのnodejsバージョンをインストールできます。
#!/bin/bash
# usage :
#
# edit two vars in below : NODE_VER and CODE_PARENT_DIR
#
# ... execute this script as yourself unless you choose a root owned value for var CODE_PARENT_DIR
# whichever id you execute this as determines the id you will issue npm commands as : npm install -g foo-bar
#
# NOTE - nodejs comes bundled with npm ... so no need to do separate npm install
# this scripts runs fine on linux or OSX
# ... copy all the lines starting here .. top of copy .... and ending ... end of copy ...
# and paste into your ~/.bashrc file so proper env vars get set
# ............... top of copy ........................ install_node.sh
# export NODE_VER=v7.2.0 # see available versions at https://nodejs.org/dist/
# export NODE_VER=v8.5.0 # edit this line next time you need to update nodejs
export NODE_VER=v9.3.0 # edit this line next time you need to update nodejs
# ... pick parent dir of nodejs install ... comment out or remove ONE of below
# export CODE_PARENT_DIR=/opt/code # root owned dir ... requires you to sudo prior to npm install going forward
export CODE_PARENT_DIR=${HOME} # RECOMMENDED execute as yourself including npm install
# ......... following env vars are OK no edits needed ... only ever need to edit above vars
curr_OS=$( uname )
echo curr_OS $curr_OS
if [[ "${curr_OS}" == "Darwin" ]]; then
OS_ARCH=darwin-x64
elif [[ "${curr_OS}" == "Linux" ]]; then
OS_ARCH=linux-x64
else
echo "ERROR - failed to recognize OS $curr_OS"
exit 5
fi
if [[ -z ${CODE_PARENT_DIR} ]]; then
echo "ERROR - failed to see env var CODE_PARENT_DIR"
exit 5
fi
export NODE_CODEDIR=${CODE_PARENT_DIR}/nodejs
export COMSUFFIX=tar.gz
export NODE_NAME=node-${NODE_VER}
export NODE_PARENT=${NODE_CODEDIR}/${NODE_NAME}-${OS_ARCH}
export PATH=${NODE_PARENT}/bin:${PATH}
export NODE_PATH=${NODE_PARENT}/lib/node_modules
# ............... end of copy ........................ install_node.sh
# copy and paste above from ... top of copy ... to here into your file ~/.bashrc
echo
echo "NODE_CODEDIR $NODE_CODEDIR<--"
echo
echo "mkdir -p ${NODE_CODEDIR}"
echo
mkdir -p ${NODE_CODEDIR}
echo
echo "cd ${NODE_CODEDIR}"
cd ${NODE_CODEDIR}
echo
# this is compiled code NOT source
[ -f ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} ] && rm ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} # if file exists remove
echo "wget -q --show-progress https://nodejs.org/download/release/${NODE_VER}/${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}"
wget -q --show-progress https://nodejs.org/download/release/${NODE_VER}/${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}
echo
echo "tar -C ${NODE_CODEDIR} -xf ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}"
tar -C ${NODE_CODEDIR} -xf ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX}
echo
[ -f ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} ] && rm ${NODE_NAME}-${OS_ARCH}.${COMSUFFIX} # if file exists remove
# ........... done ........... #
which node
node --version
# .... bottom of file install_node.sh
上記で回答したnvm経由でインストールしようとしていますが、ubuntu 18.04でエラーが発生しています。 次に、このプロセスを実行します。
sudo apt purge nodejs npm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
nvm install node
このコマンドを実行すると、エラー ``コマンド 'nvm'が見つからない可能性があります。つまり、 ````です。
その場合、このコマンドを実行できます。
source ~/.nvm/nvm.sh
または、ファイル/ .bashrcまたは〜/ .profileに入れて、自動的にロードできます。
その後、次のプロセスを実行できます。
nvm install node
nvm alias default node