Home > Software engineering >  package-lock.json file - how to clean it up?
package-lock.json file - how to clean it up?

Time:12-08

I am learning Next.js by following: https://nextjs.org/learn/basics/deploying-nextjs-app/setup

My package.json file looks normal:

{
  "name": "paths",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@types/node": "18.11.11",
    "@types/react": "18.0.26",
    "@types/react-dom": "18.0.9",
    "eslint": "8.29.0",
    "eslint-config-next": "13.0.6",
    "next": "13.0.6",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "typescript": "4.9.3"
  }
}

My package-lock.json file is a 217KB file (5300 lines). The problem is that some of those dependencies/versions exist on another server. When I try to deploy on Vercel, I think it can't find/access those dependencies.

I'm trying to figure out what the best way forward is. It seems like I can:

  1. not create it with package-lock=false and/or
  2. not upload package-lock.json to git.

Are those my only options?

CodePudding user response:

If you think there's something weird with package-lock.json and package.json is correct, just delete package-lock.json and node_modules and re-create them with npm i.

If you get a similar package-lock.json, then the contents of that file are accurate. If you think there's too many dependencies in it, it means that your dependencies themselves have many dependencies. Next is notoriously chunky.

  • Related