Virtualbox内で作業
[参考資料]
CentOS7.3からNode.jsとnpmをアンインストール。
https://haiju.hatenablog.com/entry/2017/12/13/165345
Node.js 11 の公式リポジトリを CentOS に追加する
https://xn--o9j8h1c9hb5756dt0ua226amc1a.com/?p=3272
[root@localhost ~]# yum info nodejs Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp-srv2.kddilabs.jp * epel: mirrors.njupt.edu.cn * extras: ftp-srv2.kddilabs.jp * remi-safe: mirror.cedia.org.ec * updates: ftp-srv2.kddilabs.jp Available Packages Name : nodejs Arch : x86_64 Epoch : 2 Version : 11.15.0 Release : 1nodesource Size : 19 M Repo : nodesource/x86_64 Summary : JavaScript runtime URL : http://nodejs.org License : MIT and ASL 2.0 and ISC and BSD Description : Node.js is a platform built on Chrome's JavaScript runtime : for easily building fast, scalable network applications. : Node.js uses an event-driven, non-blocking I/O model that : makes it lightweight and efficient, perfect for data-intensive : real-time applications that run across distributed devices. [root@localhost ~]#
[root@localhost ~]# yum install nodejs Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp-srv2.kddilabs.jp * epel: mirrors.njupt.edu.cn * extras: ftp-srv2.kddilabs.jp * remi-safe: mirror.cedia.org.ec * updates: ftp-srv2.kddilabs.jp Resolving Dependencies --> Running transaction check ---> Package nodejs.x86_64 2:11.15.0-1nodesource will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================= Package Arch Version Repository Size ================================================================================================= Installing: nodejs x86_64 2:11.15.0-1nodesource nodesource 19 M Transaction Summary ================================================================================================= Install 1 Package Total download size: 19 M Installed size: 57 M Is this ok [y/d/N]: y Installed: nodejs.x86_64 2:11.15.0-1nodesource Complete! [root@localhost ~]# node -v v11.15.0
以下、ミス
* ハマった時の操作
[1]
$ yum install nodejs
[2]
[root@localhost ~]# node -v v6.17.1 [http://www.tohoho-web.com/ex/nodejs.html] [root@localhost ~]# npm -v 3.10.10
[3]
# npm 経由でyarnをインストール npm install -g yarn /usr/bin/yarn -> /usr/lib/node_modules/yarn/bin/yarn.js /usr/bin/yarnpkg -> /usr/lib/node_modules/yarn/bin/yarn.js /usr/lib └── yarn@1.22.4 # yarnのバージョンを確認 yarn -v 1.22.4
[4] yarn初期設定
[root@localhost ~]# yarn init yarn init v1.22.4 question name (root): question version (1.0.0): question description: question entry point (index.js): question repository url: question author: question license (MIT): question private: success Saved package.json Done in 13.41s. [root@localhost ~]#
[5]
[root@localhost ~]# yarn install yarn install v1.22.4 info No lockfile found. [1/4] Resolving packages... [2/4] Fetching packages... [3/4] Linking dependencies... [4/4] Building fresh packages... success Saved lockfile. Done in 0.12s.