I have the CentOS Linux release 7.9.2009 (Core)
running in the VirtualBox, which was build by the Vagrant 2.2.19
and the Ansible 2.9.25
installed all the depedencies. On the machine there are installed:
gcc 9.3.0
python 3.6.8
node.js 16.13.1
npm 8.1.2
When the ansible executes the npm install
I get errored with the g++: error: unrecognized command line option ‘-std=gnu++14’
. I saw many questions here on the Stackoverflow, where the answers told me to upgrade the gcc to version >= 4.9. But I already have that and I’m still getting an error.
However, there is a workaround, which allows me to run the npm install
:
sudo yum install -y centos-release-scl
sudo yum install -y devtoolset-9-gcc*
scl enable devtoolset-9 bash
npm install
but I have to run this manually, after I’m logged into the CentOS by the vagrant ssh
. I’m not satisfied with this workaround because it is manual and the npm istall
must be run programatically, hence it doesn’t solve my problem.
I have tried to execute the npm install
inside the scl
from the ansible playbook.yml
:
- name: Install centos-release-scl
shell: yum install -y centos-release-scl
become: yes
- name: Install devtoolset-9
shell: yum install -y devtoolset-9-gcc*
become: yes
- name: install packages based on package.json
shell: |
scl enable devtoolset-9 bash
npm install
become: yes
but it didn’t work.
Is there a way how can I run the npm install
programatically by the ansible
without getting error?
2
Answers
You can stick with gcc 4.8.5 but downgrading to NodeJS 14 (as pointed out in https://github.com/systemd/node-sd-notify/issues/29#issuecomment-1040909033).
Note: You can download NodeJS 14 at https://github.com/nodesource/distributions/blob/master/README.md#enterprise-linux-based-distributions
For CentOS run this.
Then Install cmake.
Then run.
Install devtoolset.
Enable devtoolset.