skip to Main Content

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


  1. For CentOS run this.

    yum install gcc-c++
    

    Then Install cmake.

    yum install cmake
    

    Then run.

    yum install centos-release-scl
    

    Install devtoolset.

    yum install devtoolset-8-gcc devtoolset-8-gcc-c++
    

    Enable devtoolset.

    scl enable devtoolset-8 -- bash
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search