I am working on a pipeline to install npm packages using GitHub Actions, I am getting this error:
npm ERR! code EUSAGE
npm ERR!
npm ERR! The `npm ci` command can only install with an existing package-lock.json or
npm ERR! npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or
npm ERR! later to generate a package-lock.json file, then try again.
npm ERR!
npm ERR! Clean install a project
npm ERR!
npm ERR! Usage:
npm ERR! npm ci
npm ERR!
npm ERR! Options:
npm ERR! [--no-audit] [--foreground-scripts] [--ignore-scripts]
npm ERR! [--script-shell <script-shell>]
npm ERR!
npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
npm ERR!
npm ERR! Run "npm help ci" for more info
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2022-09-09T06_53_34_562Z-debug-0.log
Error: Process completed with exit code 1.
My pipeline looks like this :
name: Veracode frontend Scan
on:
workflow_dispatch:
jobs:
veracode:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
If anyone can help me out, I am not sure where I am going wrong.
3
Answers
Check first if this is related to
actions/setup-node
issue 498 or PR 103The
npm-ci
command does mention:Make sure:
npm
project does create apackage-lock.json
(which it should by default).gitignore
) and is part of your repository codebase.As noted here:
The OP learner confirms in the comments a path issue:
But the error message becomes:
From this answer, a
npm ci --force
is one way to go forward in that case.Seems you miss to checkout the code first, just add the actions/checkout step, as example: