Hi i am trying to use the Vue CLI Service for testing and building my VueJS App but when I try to run the vue-cli-service command it says command not found. I tried installing it globally but that is not allowed however.
build-and-test:
docker:
- image: cimg/node:12.22.1
steps:
- checkout
- run:
name: Install Vue CLI
command: npm i @vue/cli
- node/install-packages
- run:
name: Run tests
command: vue-cli-service test:e2e --headless --spec tests/e2e/specs/test.js```
Hey @DatIsNiels,
To use an NPM module directly in the command line, you will need to install the npm package globally.
npm install -g @vue/cli
Reference: @vue/cli - npm
First, try installing the package globally. If this still does not resolve the issue, it may be that the node module is not in your path. Different run steps do not run within the same shell and they are non-login shells, so they do not load from .bashrc
or the like.
There are a few ways to resolve this, I would recommend one of these two:
- Combine the steps. Rather than
Install Vue CLI
being its own step, package it in with Run Tests
.
build-and-test:
docker:
- image: cimg/node:12.22.1
steps:
- checkout
- node/install-packages
- run:
name: Run tests
command: |
npm i @vue/cli -g
vue-cli-service test:e2e --headless --spec tests/e2e/specs/test.js
- Export the proper path to
$BASH_ENV
https://circleci.com/docs/2.0/env-vars/#using-parameters-and-bash-environment
build-and-test:
docker:
- image: cimg/node:12.22.1
steps:
- checkout
- run:
name: Install Vue CLI
command: |
npm i @vue/cli -g
echo "export PATH=$PATH:/usr/local/lib/node_modules" >> "$BASH_ENV"
- node/install-packages
- run:
name: Run tests
command: |
vue-cli-service test:e2e --headless --spec tests/e2e/specs/test.js
Hi, thanks for your response. I tried both of your solutions. But I am not allowed to install it globally.
When I try I get this error message
I also tried it without the global parameter however it still says that the command cannot be found.