Expand Your Project with External Packages from npm

I did exactly what the challenge asked me too and added

"dependencies": {
	"express": "^4.14.0",
	"@freecodecamp/example": "1.1.0"
}

to my json file and comitted and pushed, but then the deployment fails and I get this message from Cyclic (the tool I’m using to deploy since replit is not free):

2023-12-13T17:46:28.499Z: [CYCLIC] cloning…
2023-12-13T17:46:29.026Z: Setting environment variables:
CYCLIC_URL=“http****************”
CYCLIC_DB=“dull****************”
CYCLIC_BUCKET_NAME=“cycl****************”
CYCLIC_APP_ID=“dull****************”
2023-12-13T17:46:29.032Z: From GitHub - Vinni-Cedraz/starter-micro-api

  • branch 02e05b931f401e31627d917b6d6ed9a060551c3e → FETCH_HEAD
    2023-12-13T17:46:29.036Z: HEAD is now at 02e05b9 06 - dependencies
    2023-12-13T17:46:29.043Z: [CYCLIC] Building…
    2023-12-13T17:46:29.225Z: Build Configuration:
    Root Path: /
    Output Path: /
    Static Site: false
    Runtime: nodejs18.x
    Branch: main
    Ref: 02e05b931f401e31627d917b6d6ed9a060551c3e

2023-12-13T17:46:29.510Z: [CYCLIC] verifying…
2023-12-13T17:46:29.578Z: [CYCLIC] using: node:v18.18.2 npm:10.1.0 runtime:nodejs18.x
[CYCLIC] building from: /
2023-12-13T17:46:29.631Z: [CYCLIC] installing dependencies from: package-lock.json
2023-12-13T17:46:32.213Z: npm ERR! code EUSAGE
2023-12-13T17:46:32.216Z: npm
2023-12-13T17:46:32.219Z: ERR!
npm ERR! npm ci can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with npm install before continuing.
npm ERR!
npm ERR! Missing: @freecodecamp/example@1.1.0 from lock file
npm ERR!
npm ERR! Clean install a project
npm ERR!
npm ERR! Usage:
npm ERR! npm ci
npm ERR!
npm ERR! Options:
npm ERR! [–install-strategy <hoisted|nested|shallow|linked>] [–legacy-bundling]
npm ERR! [–global-style] [–omit <dev|optional|peer> [–omit <dev|optional|peer> …]]
npm ERR! [–strict-peer-deps] [–foreground-scripts] [–ignore-scripts] [–no-audit]
npm ERR! [–no-bin-links] [–no-fund] [–dry-run]
npm ERR! [-w|–workspace [-w|–workspace …]]
npm ERR! [-ws|–workspaces] [–include-workspace-root] [–install-links]
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: /tmp/vinni-cedraz-starter-micro-api/.npm/_logs/2023-12-13T17_46_29_932Z-debug-0.log
2023-12-13T17:46:32.228Z: [CYCLIC] Build Failed

Then, if the deployment failed, nothing in my URL changeda
So I get an error message from freecodecamp’s challenge:
// running tests

"dependencies"

should include

"@freecodecamp/example"

version should be

"1.1.0"

. // tests completed

Replit is free, they have a free tier.

Anyway, you can try deleting the lock file (package-lock.json) from your repo and see if that helps with the deployment on Cyclic.

Removing the -lock file solved the issue entirely, any ideas on what this worked?

npm ERR! npm ci can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with npm install before continuing.
npm ERR!
npm ERR! Missing: @freecodecamp/example@1.1.0 from lock file

I guess it is expected that npm install was run before the deploy. So you can’t just add dependencies to the package.json file without also updating the lock file by running the install.

So why was it fixed by deleting the lock file instead of running npm install? And would npm install work on a mock package @freecodecamp/example ?

It should work either way and yes running npm install should update the lock file with the mock package.

I would assume as long as you can run npm ci locally it would work on Cyclic as well.