Eval: line 199: npx: not found - CI/CD kubernetes

Hi everyone!

I’ve been trying to execute e2e tests of my app with codeceptjs into CI/CD kubernetes container, but i got this error each time :

eval: line 199: npx: not found
eval: line 199: npx: not found

This is the executed script CLI :

docker-compose run e2e echo '127.0.0.1 georedv3' >> /etc/hosts && npx serve ./dist -p 8080 & sleep 10 && npx codeceptjs run --steps

Any suggestions / ideas how to deal with this issue ??

Regards,

Hi @herrouhajar

This just means that your server or container doesn’t have npx installed. You either need to install it in your Dockerfile or .gitlab-ci.yml script, or use a different image for that job.

1 Like

Hi @snim2 ,

Actually, npx is installed because when i try with npx --version, it works fine, I run npm i before all these CLIs, and also there are other CLI executed fine using npx before this one :

docker-compose run e2e npx playwright install
docker-compose run e2e npx vue-cli-service build

So i wonder why I got the error when I try this :

docker-compose run e2e echo '127.0.0.1 georedv3' >> /etc/hosts && npx serve ./dist -p 8080 & sleep 10 && npx codeceptjs run --steps

So, does npx --version work on its own, or do you mean docker-compose run e2e npx --version?

1 Like

@snim2 I mean with this : docker-compose run e2e npx -version : 8.5.5

OK, so in your longer command:

docker-compose run e2e echo '127.0.0.1 georedv3' >> /etc/hosts && npx serve ./dist -p 8080 & sleep 10 && npx codeceptjs run --steps

Are you intending npx to run in docker-compose or on your host? I’m just wondering if you need some more quoting here, somewhere?

@snim2 so what i need to achieve withing this command is to launch localhost on port 8080, and then execute automated tests on it all that in docker-compose, it’s working as expected on my local but when it cames to ci/cd it’s not the case

TBH because it’s quite a complex command, personally I’d write a shell script and just call the script from your .gitlab-ci.yml file. That way you don’t need to worry about anything that’s GitLab-specific.