Reputation: 1090
I use gitlab CI to deploy vuejs app. For staging, everything works great. I copy paste the same configuration for production and I have :
$ npm run build
> cross-env NODE_ENV=production && vue-cli-service build
sh: 1: cross-env: not found
Here is the .yml file :
build-prod:
stage: build-prod
image: node:latest
variables:
NODE_ENV: production
rules:
# only run on master builds, we'll deal with branch builds next
- if: '$CI_COMMIT_BRANCH == "main"'
when: on_success
- when: never
script:
- node --version
- npm --version
- ls
- cd front
- ls
- npm install -g @vue/cli-service@latest
- rm -rf node_modules
- npm install
- npm install cross-env
- npm run build <----------------------------------- Error here
- ls
I also tried to manually clean cache on gitlab but no effect.
In staging steps are exactly the same and everything works, how can I deal with it ?
Upvotes: 0
Views: 1076
Reputation: 2310
Why do you not install cross-env
globally?
npm install --global cross-env
I successfully tested this solution with the node:latest
image, the same you're using in the CI:
$ podman run --rm -it docker.io/node:latest bash
root@35ac5bda21eb:/# node --version
v16.12.0
root@35ac5bda21eb:/# npm --version
8.1.0
root@35ac5bda21eb:/# cross-env
bash: cross-env: command not found
root@35ac5bda21eb:/# export NODE_ENV=production
root@35ac5bda21eb:/# npm install --global cross-env
added 7 packages, and audited 8 packages in 1s
found 0 vulnerabilities
npm notice
npm notice New patch version of npm available! 8.1.0 -> 8.1.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.1.1
npm notice Run npm install -g [email protected] to update!
npm notice
root@35ac5bda21eb:/# which cross-env
/usr/local/bin/cross-env
Upvotes: 0