2021年2月8日月曜日

ubuntu node.js インストール

正式版 本家

ダウンロードしたbinaryを/usr/local/lib/nodejsに展開してpathを通す。

LTSの確認 nodejsのホームページで確認する。
 VERSION=v14.15.4
 DISTRO=linux-x64
 wget https://nodejs.org/dist/$VERSION/node-$VERSION-$DISTRO.tar.xz
sudo mkdir -p /usr/local/lib/nodejs sudo tar -xJvf node-$VERSION-$DISTRO.tar.xz -C /usr/local/lib/nodejs

~/.profileの最後に下記を追加する。

# Nodejs
VERSION=v14.15.4
DISTRO=linux-x64
export PATH=/usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin:$PATH

profileを更新する。

. ~/.profile

テスト

node -v

npm version

npx -v



APT INSTALL

$ sudo apt install nodejs npm

$ nodejs --version   <== コマンドはnodejs

v10.19.0   <== 古い


node.jsのバージョン管理モジュールをインストール

$ sudo npm install n -g

stableの最新版をインストール
$ sudo n stable
  installing : node-v14.15.4
       mkdir : /usr/local/n/versions/node/14.15.4
       fetch : https://nodejs.org/dist/v14.15.4/node-v14.15.4-linux-x64.tar.xz
   installed : v14.15.4 (with npm 6.14.10)

Note: the node command changed location and the old location may be remembered in your current shell.
         old : /usr/bin/node
         new : /usr/local/bin/node
To reset the command location hash either start a new shell, or execute PATH="$PATH"

$ node --version
v14.15.4

$ sudo apt purge -y nodejs npm
$ exec $SHELL -l

ここまで

参考

$ sudo apt autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  fontconfig-config fonts-dejavu-core gyp javascript-common
  libauthen-sasl-perl libc-ares2 libdata-dump-perl libdrm-amdgpu1
  libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libencode-locale-perl
  libfile-basedir-perl libfile-desktopentry-perl libfile-listing-perl
  libfile-mimeinfo-perl libfont-afm-perl libfontconfig1 libfontenc1 libgl1
  libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0
  libhtml-form-perl libhtml-format-perl libhtml-parser-perl
  libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl
  libhttp-daemon-perl libhttp-date-perl libhttp-message-perl
  libhttp-negotiate-perl libice6 libio-html-perl libio-socket-ssl-perl
  libio-stringy-perl libipc-system-simple-perl libjs-inherits
  libjs-is-typedarray libjs-psl libjs-typedarray-to-buffer libllvm11
  liblwp-mediatypes-perl liblwp-protocol-https-perl libmailtools-perl
  libnet-dbus-perl libnet-http-perl libnet-smtp-ssl-perl libnet-ssleay-perl
  libnode-dev libnode64 libpciaccess0 libpython2-stdlib libpython2.7-minimal
  libpython2.7-stdlib libsensors-config libsensors5 libsm6 libssl-dev
  libtie-ixhash-perl libtimedate-perl libtry-tiny-perl liburi-perl libuv1-dev
  libvulkan1 libwayland-client0 libwww-perl libwww-robotrules-perl
  libx11-protocol-perl libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-dri3-0
  libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-shape0 libxcb-sync1
  libxcb-xfixes0 libxcomposite1 libxcursor1 libxdamage1 libxfixes3 libxft2
  libxi6 libxinerama1 libxkbfile1 libxml-parser-perl libxml-twig-perl
  libxml-xpathengine-perl libxmu6 libxpm4 libxrandr2 libxrender1 libxshmfence1
  libxt6 libxtst6 libxv1 libxxf86dga1 libxxf86vm1 mesa-vulkan-drivers
  nodejs-doc perl-openssl-defaults python-pkg-resources python2
  python2-minimal python2.7 python2.7-minimal x11-common x11-utils
  x11-xserver-utils xdg-utils
0 upgraded, 0 newly installed, 115 to remove and 0 not upgraded.
After this operation, 475 MB disk space will be freed.
Do you want to continue? [Y/n] 

0 件のコメント:

コメントを投稿