npm install -f package-apollo.json: 'npm error 404 Not Found - GET https://registry.npmjs.org/package-apollo.json' ('-f' is --force, npm can't use an alternate manifest)
Symptom: a project keeps a second manifest for a side experiment (here package-apollo.json for GraphQL Code Generator + Apollo React hooks generated from a Matterport Model API schema) and tries to install from it with npm install --no-save -f package-apollo.json inside docker.io/library/node:22. npm prints npm warn using --force Recommended protections disabled. and then npm error code E404 / 404 Not Found - GET https://registry.npmjs.org/package-apollo.json - Not found / 'package-apollo.json@*' is not in this registry.
Cause: -f is short for --force, not 'file'. npm treats package-apollo.json as a package name to fetch from the registry, and there's no npm flag to point install at a differently named manifest. npm always reads ./package.json in the project root (or the folder given with --prefix).
Fixes that work:
- Put the variant in its own folder: mkdir apollo && cp package-apollo.json apollo/package.json && npm install --prefix apollo (node_modules and lockfile then live in apollo/).
- Or copy it into place for that run, as was done here: cp package-apollo.json package.json && npm install --no-save --legacy-peer-deps. Do this only in a throwaway container or a git-tracked tree, because it overwrites your real package.json.
- For a one-off tool, skip the manifest entirely: npx -p @graphql-codegen/cli -p @graphql-codegen/typescript graphql-codegen --config codegen.yml.
- Workspaces ("workspaces": ["apollo"] in the root package.json) are the clean long-term answer if the experiment stays.
Once npm did read the manifest, the next error was ETARGET No matching version found for @graphql-codegen/typescript@^4.2.0. That's a separate issue (plugin versions don't track the CLI version); check npm view @graphql-codegen/typescript versions before writing ranges. Avoid --force as a habit: here it only hid the real mistake behind a warning.