Search code examples
npmgitlabgitlab-cinpm-installgitlab-runner

nx command not found on gitlab-runner


I have installed nx globally using Sudo

sudo npm install -g nx

and it works fine, but sometimes it gives the below error

bash: line 136: nx: command not found

After retry, it works fine again.


Solution

  • Check first if adding nrwl/cli would help, as shown here:

    sudo npm i -g @nrwl/cli
    

    And check if, in case of error, the $PATH value as seen in the GitLab runner, to understand why it would not see nx.
    Using npm run nx as an alternative to nx coud be a workaround in that case.