I started out with a simple task... install Tailwindcss. What unfolded is something that many of us have experienced time and time again.
For anyone that has completed this task before knows that through shell the command is
# Using npm npm install tailwindcss
However, before doing so I wanted to check the version of node on the server and in Plesk. The shell command node -v was showing v7.10.1 whereas in Plesk v10.16.0. Not great being a few versions behind. But to top this situation off, npm (npm -v) presented me with the following error
module.js:472 throw err; ^ Error: Cannot find module './config/core.js' at Function.Module._resolveFilename (module.js:470:15) at Function.Module._load (module.js:418:25) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at /usr/lib/node_modules/npm/lib/npm.js:25:17 at Object.<anonymous> (/usr/lib/node_modules/npm/lib/npm.js:444:3) at Module._compile (module.js:571:32) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12)
So no Tailwindcss installation for the moment.
Even though I covered some of the version above, I'm going to take you through this step by step. So let’s check the current version and location of Node.js and npm (the Node.js package manager) and location:
$ node -v v7.10.1 $ npm -v not working $ which node /usr/bin/node $ which npm /usr/bin/npm
Nodejs 7.x is not supported so I need to move on from this asap. If can see from https://nodejs.org/en/about/releases/ that the last Active LTS version is v12. Before nodejs is installed, you need to remove it
sudo yum remove -y nodejs npm
Installing nodejs and npm
To get the curl for v12 go to https://github.com/nodesource/distributions#rpminstall and you'll see that the most suited is
# As root curl -sL https://rpm.nodesource.com/setup_12.x | bash - # No root privileges curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash -
The curl command will first use the curl tool to download the “setup_12.x” script and then execute this script using bash. Output from the script will look like:
## Installing the NodeSource Node.js 12.x repo... ## Inspecting system... + rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release + uname -m ## Confirming "el6-x86_64" is supported... + curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_12.x/el/6/x86_64/nodesource-release-el6-1.noarch.rpm' ## Downloading release setup RPM... + mktemp + curl -sL -o '/tmp/tmp.fRBRGeaeHD' 'https://rpm.nodesource.com/pub_12.x/el/6/x86_64/nodesource-release-el6-1.noarch.rpm' ## Installing release setup RPM... + rpm -i --nosignature --force '/tmp/tmp.fRBRGeaeHD' ## Cleaning up... + rm -f '/tmp/tmp.fRBRGeaeHD' ## Checking for existing installations... + rpm -qa 'node|npm' | grep -v nodesource ## Run `sudo yum install -y nodejs` to install Node.js 12.x and npm. ## You may also need development tools to build native addons: sudo yum install gcc-c++ make ## To install the Yarn package manager, run: curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo sudo yum install yarn
As the comment notes above, to install Node.js 12.x and npm execute the command
sudo yum install -y nodejs
However, in doing so the following error came up
Resolving Dependencies --> Running transaction check ---> Package nodejs.x86_64 2:12.16.1-1nodesource will be installed --> Processing Dependency: libc.so.6(GLIBC_2.17)(64bit) for package: 2:nodejs-12.16.1-1nodesource.x86_64 --> Finished Dependency Resolution Error: Package: 2:nodejs-12.16.1-1nodesource.x86_64 (nodesource) Requires: libc.so.6(GLIBC_2.17)(64bit) You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofiles --nodigest
However, this is the start of issues with installing 12.x. With the server running on Centos6 there are too many dependancies that thwart this process. So, let's progress with v10 instead.
Make sure you remove the cache version of the installer. Do this by running the command:
rm -rf /var/cache/yum/*
Re use the curl command that was commented above for setup_12.x, now for setup_10.x.
curl -sL https://rpm.nodesource.com/setup_10.x | bash -
Run the installer script
sudo yum install -y nodejs
A successful installation will look like the following output
Resolving Dependencies --> Running transaction check ---> Package nodejs.x86_64 2:10.22.0-1nodesource will be installed --> Finished Dependency Resolution Dependencies Resolved ==================================================================================================== Package Arch Version Repository Size ==================================================================================================== Installing: nodejs x86_64 2:10.22.0-1nodesource nodesource 20 M Transaction Summary ==================================================================================================== Install 1 Package(s) Total download size: 20 M Installed size: 61 M Downloading Packages: nodejs-10.22.0-1nodesource.x86_64.rpm | 20 MB 00:01 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : 2:nodejs-10.22.0-1nodesource.x86_64 1/1 Verifying : 2:nodejs-10.22.0-1nodesource.x86_64 1/1 Installed: nodejs.x86_64 2:10.22.0-1nodesource Complete!
Check the versions of nodejs and npm
$ node -v v10.22.0 $ npm -v 6.14.6
Okay now I'll go and install Tailwindcss!