I have been trying to learn CircleCi workflows by building simple jobs and I keep getting this error:
/bin/bash: yarn: command not found
.
So all the steps run but when it comes to the job is self it stops. So spin up environment, preparing env variables, checkout code, Restore Yarn Package Cache are green(successful).
My workflow below:
JavaScript
x
66
66
1
default-environment: &default-environment
2
docker:
3
- image: cimg/base:2020.01
4
5
step-restore-build-cache: &step-restore-build-cache
6
restore_cache:
7
name: Restore Yarn Package Cache
8
keys:
9
- yarn-packages-{{ checksum "yarn.lock" }}
10
11
step-save-build-cache: &step-save-build-cache
12
save_cache:
13
name: Save Yarn Package Cache
14
key: yarn-packages-{{ checksum "yarn.lock" }}
15
paths:
16
- ~/.cache/yarn
17
18
step-run-cache: &step-run-cache
19
run:
20
name: Install Dependencies
21
command: yarn install --immutable
22
23
version: 2.1
24
jobs:
25
build:
26
<<: *default-environment
27
steps:
28
- checkout
29
- <<: *step-restore-build-cache
30
- run:
31
name: Build
32
command: yarn run build
33
- <<: *step-save-build-cache
34
lint:
35
<<: *default-environment
36
steps:
37
- checkout
38
- <<: *step-restore-build-cache
39
- run:
40
name: Lint
41
command: yarn run lint
42
format:
43
<<: *default-environment
44
steps:
45
- checkout
46
- <<: *step-restore-build-cache
47
- run:
48
name: Format
49
command: yarn run format
50
type-check:
51
<<: *default-environment
52
steps:
53
- checkout
54
- <<: *step-restore-build-cache
55
- run:
56
name: Type-check
57
command: yarn run type-check
58
workflows:
59
version: 2
60
build-and-lint:
61
jobs:
62
- build
63
- lint
64
- format
65
- type-check
66
Not really sure how to fix this..
Thank you very much 🙂
Advertisement
Answer
You’re using cimg/base:2020.01
which is a general purpose image and does not have node or the yarn binary installed. You should use the cimg/node image which has yarn pre-installed.