The Goal: 'npx elm make' running successfully in a GitLab CD
Background: I have a bit of a toy frontend project on GitLab pages, and I've written a crude CI/CD pipeline for it. This includes building a subdirectory with elm files. It worked for a while and then suddenly broke, and I can't seem to fix it.
The script is as follows:
cd public/scripts/
npm i
cd elm/
npx elm make src/Main.elm --output=index.js
and then continues with the rest of the script.
These instructions work fine on my machine.
The issue: 'npx elm make' looks for a package.json in the elm directory.
Here is the output from the failed build:
Running with gitlab-runner 13.5.0-rc2 (71c90c86)
on docker-auto-scale z3WU8uu-
Resolving secrets
00:00
Preparing the "docker+machine" executor
Using Docker executor with image node:latest ...
Pulling docker image node:latest ...
Using docker image sha256:ca36fba5ad66b0f8fce2b97a6f0aa53267395388ada988534d848638312ccb68 for node:latest with digest node@sha256:bf60a164bc588967ce6e3342c9d6508bf9ad2e7e2a1c237315596eab3e13428b ...
Preparing environment
00:03
Running on runner-z3wu8uu--project-21153296-concurrent-0 via runner-z3wu8uu--srm-1603581774-6b7f1e48...
Getting source from Git repository
00:23
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/chicagotestout/chicagotestout.gitlab.io/.git/
Created fresh repository.
Checking out b73b89bb as master...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:01
$ cd public/scripts/
$ npm i
up to date, audited 49 packages in 644ms
found 0 vulnerabilities
$ cd elm/
$ npx elm make src/Main.elm --output=index.js
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /builds/chicagotestout/chicagotestout.gitlab.io/public/scripts/elm/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/builds/chicagotestout/chicagotestout.gitlab.io/public/scripts/elm/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-10-24T23_24_44_668Z-debug.log
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1
So it's looking for a package.json file in the elm subdirectory. Okay. But I don't have (and don't need, and don't want) a package.json file there. The relevant package.json file is in its parent directory (scripts) where elm is installed.
Confounding factors
You might be wondering what was in the commit that broke the build when it quit working, but there's nothing in that commit that should have broken the build in this way. The commit didn't touch any configuration files, just some .elm source files.
My gut says this is an npm thing, but I can't quite rule out the idea that this is an elm thing or a gitlab-ci thing.
I've searched for this issue, but it seems like this is a pretty uncommon issue, and I'm struggling to filter out a heap of other package.json search terms.
In Conclusion
How do I get npx
to look in the parent directory for the appropriate package.json?
Help appreciated.